From 031be5fc796d952f26f779e1bd9aae6b5c0f56ae Mon Sep 17 00:00:00 2001 From: Fisch Date: Sun, 31 Jan 2021 13:08:48 +0100 Subject: [PATCH] basic motor driver shield test --- platformio.ini | 19 ++++++++++++++++ src/main.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 platformio.ini create mode 100644 src/main.cpp diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 0000000..427fdcb --- /dev/null +++ b/platformio.ini @@ -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 \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..c664126 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,61 @@ +#include +#include + + +#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); + +}