basic motor driver shield test

This commit is contained in:
interfisch 2021-01-31 13:08:48 +01:00
commit 031be5fc79
2 changed files with 80 additions and 0 deletions

19
platformio.ini Normal file
View File

@ -0,0 +1,19 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
monitor_speed = 57600
lib_deps =
https://github.com/thomasfredericks/wemos_motor_shield

61
src/main.cpp Normal file
View File

@ -0,0 +1,61 @@
#include<Arduino.h>
#include <Wire.h>
#include "WEMOS_Motor.h"
//follow firmware flash guide for new wemos motor shield v1.0 https://github.com/thomasfredericks/wemos_motor_shield
//Motor shield default I2C Address: 0x30
//PWM frequency: 1000Hz(1kHz)
Motor M1(0x30, _MOTOR_A, 1000); //Motor A
Motor M2(0x30, _MOTOR_B, 1000); //Motor B
void setup() {
Serial.begin(57600);
Serial.println("Starting demo");
}
void loop() {
int pwm;
for (pwm = 0; pwm <= 100; pwm++)
{
M1.setmotor( _CW, pwm);
M2.setmotor(_CW, pwm);
Serial.print("Clockwise PWM: ");
Serial.println(pwm);
delay(100);
}
Serial.println("Motor STOP");
M1.setmotor(_STOP);
M2.setmotor( _STOP);
delay(1000);
for (pwm = 0; pwm <= 100; pwm++)
{
M1.setmotor(_CCW, pwm);
//delay(1);
M2.setmotor(_CCW, pwm);
Serial.print("Counterclockwise PWM: ");
Serial.println(pwm);
delay(100);
}
Serial.println("Motor A&B STANDBY");
M1.setmotor(_STANDBY);
M2.setmotor( _STANDBY);
delay(1000);
}