Hi.
Somebody used the WEMOS library from
WEMOS_Motor_Shield_Arduino_Library
for communicating with Arduino UNO?
I'm attached WEMOS motor shield.
Upgrade with new firmware from here:
hackaday
Simple code easy to detected shield on address 0x30 but nothing happened when I'm trying to use the simple WEMOS library example code.
Like this:
#include "WEMOS_Motor.h"
int pwm;
//Motor shiled I2C Address: 0x30
//PWM frequency: 1000Hz(1kHz)
Motor M1(0x30, _MOTOR_A, 1000); //Motor A
void setup() {
Serial.begin(9600);
}
void loop() {
for (pwm = 40; pwm <= 100; pwm++)
{
M1.setmotor( _CW, pwm);
// sprintf( txt, "A:%d%, B:%d%, DIR:CW\r\n", pwm, 100 - pwm);
Serial.println( txt );
delay(500);
M1.setmotor(_STANDBY);
Serial.println("Motor A STANDBY");
delay(100);
}
It doesn't work.
Ok.
I'm found some idea.
In the code of class Motor using some code that can't be used before setup module in Arduino code :o
Solution is:
#include "WEMOS_Motor.h"
int pwm;
//Motor shiled I2C Address: 0x30
//PWM frequency: 1000Hz(1kHz)
Motor *M1;
void setup() {
M1 = new Motor(0x30, _MOTOR_A, 1000); //Motor A
Serial.begin(9600);
}
void loop() {
for (pwm = 40; pwm <= 100; pwm++)
{
M1->setmotor( _CW, pwm);
// sprintf( txt, "A:%d%, B:%d%, DIR:CW\r\n", pwm, 100 - pwm);
Serial.println( txt );
delay(500);
M1->setmotor(_STANDBY);
Serial.println("Motor A STANDBY");
delay(100);
}
But it doesn't work anyway >:(
I made the setup "log":
void setup() {
M1 = new Motor(0x30, _MOTOR_A, 1000); //Motor A
Serial.begin(9600);
Serial.println("Let's start!");
}
Wtf!
Now it's work perfectly!!!
Without using Serial it works fine.
With "setup" using Serial.print function it works fine.
But what's wrong?