Greetings,
I am new and just purchased a DFRduino Romeo V1.1.
I have two motors hook up to the M1 and M2.
With the default code come with the Romeo
The Romeo was able to turn the two motors when I turned on the Romeo.
Then, I come across this link
http://www.dfrobot.com/wiki/index.php/DFRduino_Romeo-All_in_one_Controller_V1.1(SKU:DFR0004)
and decide to give this sample codes below a try. After I compiled and uploaded to the Romeo.
The motor is stop working and the green light stop blinking as well.
No quite sure where to go from there and how to start with some sample codes to test out the M1 and M2.
WOuld you guys provide some guidance on how to start from here.
Where can I download the orginal codes?
What do I need to modify in the sample codes to get these two motor working again?
Thank you very much,
T
//Standard PWM DC control
int E1 = 5; //M1 Speed Control
int E2 = 6; //M2 Speed Control
int M1 = 4; //M1 Direction Control
int M2 = 7; //M1 Direction Control
///For previous Romeo, please use these pins.
//int E1 = 6; //M1 Speed Control
//int E2 = 9; //M2 Speed Control
//int M1 = 7; //M1 Direction Control
//int M2 = 8; //M1 Direction Control
void stop(void) //Stop
{
digitalWrite(E1,LOW);
digitalWrite(E2,LOW);
}
void advance(char a,char b) //Move forward
{
analogWrite (E1,a); //PWM Speed Control
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void back_off (char a,char b) //Move backward
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
void turn_L (char a,char b) //Turn Left
{
analogWrite (E1,a);
digitalWrite(M1,LOW);
analogWrite (E2,b);
digitalWrite(M2,HIGH);
}
void turn_R (char a,char b) //Turn Right
{
analogWrite (E1,a);
digitalWrite(M1,HIGH);
analogWrite (E2,b);
digitalWrite(M2,LOW);
}
void setup(void)
{
int i;
for(i=4;i<=7;i++)
pinMode(i, OUTPUT);
Serial.begin(19200); //Set Baud Rate
Serial.println("Run keyboard control");
}
void loop(void)
{
if(Serial.available()){
char val = Serial.read();
if(val != -1)
{
switch(val)
{
case 'w'://Move Forward
advance (255,255); //move forward in max speed
break;
case 's'://Move Backward
back_off (255,255); //move back in max speed
break;
case 'a'://Turn Left
turn_L (100,100);
break;
case 'd'://Turn Right
turn_R (100,100);
break;
case 'z':
Serial.println("Hello");
break;
case 'x':
stop();
break;
}
}
else stop();
}
}