Forum >Problem with M2 PWM on Romeo v2
Problem with M2 PWM on Romeo v2

Hello
I have a problem with Romeo v2.2 in Devastator. Well, the DC motor connected to the M2 connectors only works when the PWM signal is set to 255. Anything less than 255 means that the motor is not running. The direction of rotation does not matter. Romeo board is new. The DC motor is operational, since it is working properly when connected to M1. Romeo is also connected to an IR receiving diode (pin 2) and a 433mhz receiver (pin 3, I don't use it yet). I'm using a modified sketch from https://wiki.dfrobot.com/Romeo_V2-All_i ... KU_DFR0225_. Does any of you have any ideas why it does not work as it should?
I have a problem with Romeo v2.2 in Devastator. Well, the DC motor connected to the M2 connectors only works when the PWM signal is set to 255. Anything less than 255 means that the motor is not running. The direction of rotation does not matter. Romeo board is new. The DC motor is operational, since it is working properly when connected to M1. Romeo is also connected to an IR receiving diode (pin 2) and a 433mhz receiver (pin 3, I don't use it yet). I'm using a modified sketch from https://wiki.dfrobot.com/Romeo_V2-All_i ... KU_DFR0225_. Does any of you have any ideas why it does not work as it should?
Code: Select all
#include <IRremote.h> const int OdbiorIR = 2; IRrecv irrecv(OdbiorIR); decode_results results; int komenda; int E1 = 5; //M1 Speed Control int E2 = 6; //M2 Speed Control int M1 = 4; //M1 Direction Control int M2 = 7; //M1 Direction Control int bieg; void stop(void) //Stop { digitalWrite(E1,LOW); digitalWrite(E2,LOW); } void DoPrzodu(int a,int b) //Move forward { analogWrite (E1,a); //PWM Speed Control digitalWrite(M1,HIGH); analogWrite (E2,b); digitalWrite(M2,HIGH); } void DoTylu (int a,int b) //Move backward { analogWrite (E1,a); digitalWrite(M1,LOW); analogWrite (E2,b); digitalWrite(M2,LOW); } void ObrotLewo (int a,int b) //Turn Left { analogWrite (E1,a); digitalWrite(M1,LOW); analogWrite (E2,b); digitalWrite(M2,HIGH); } void ObrotPrawo (int a,int b) //Turn Right { analogWrite (E1,a); digitalWrite(M1,HIGH); analogWrite (E2,b); digitalWrite(M2,LOW); } void setup(void) { Serial.begin(9600); Serial.println("Rozpoczęto komunikację z PC!"); irrecv.enableIRIn(); irrecv.blink13(true); stop(); bieg=255; } void loop(void) { if (irrecv.decode(&results)){ Serial.println(results.value, HEX); komenda=results.value; Serial.print("Znaleziono: "); Serial.println(komenda); irrecv.resume(); switch(komenda) { case -28561: bieg=100; break; case -30601: bieg=170; break; case -14281: bieg=255; break; case 1275: DoPrzodu (bieg, bieg); //move forward break; case 1785://Move Backward DoTylu (bieg, bieg); //move back break; case -14535://Turn Left ObrotLewo (bieg, bieg); break; case -10201://Turn Right ObrotPrawo (bieg, bieg); break; case -2041: stop(); break; } } }
2019-07-02 19:15:47
Please use this code, if it still can't work, contact us at [email protected] to replace.
techsupport
Code: Select all
Please ensure that the jumper on the board is shorted (supports PWM control mode.) and the motor is normal.int E1 = 5; int E2 = 6; int M1 = 4; int M2 = 7; void setup() { int i; for(i=4;i<=7;i++) pinMode(i, OUTPUT); Serial.begin(19200); //设置串口波特率 } void loop() { analogWrite (E1,100); digitalWrite(M1,HIGH); Serial.println("555"); analogWrite (E2,100); digitalWrite(M2,HIGH); Serial.println("666"); }
Please use this code, if it still can't work, contact us at [email protected] to replace.
