Problem with romeo example

hello guys..im new to this world especially arduino :) i just bought 4WD and roboduino romeo.The problem is after uploading the example,it does not move.Here i attach the example i use and my 4WD romeo picture

//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=6;i<=9;i++)
pinMode(i, OUTPUT);
Serial.begin(19200); //Set Baud Rate
}
void loop(void)
{
char val = Serial.read();
if(val!=-1)
{
switch(val)
{
case 'w'://Move Forward
advance (100,100); //PWM Speed Control
break;
case 's'://Move Backward
back_off (100,100);
break;
case 'a'://Turn Left
turn_L (100,100);
break;
case 'd'://Turn Right
turn_R (100,100);
break;
}
delay(40);
}
else stop();
}

 

 

Do i make a mistake about the 4WD romeo connection or the example? if i do,please guide me :)

thanks :)

It’s hard to tell or judge

It’s hard to tell or judge where may goes wrong. Try to narrow down the problems. ex: Connect battery to motors and see if they are working; use multimeter to detect the pin got correct current etc.

You defined Pin 4,5,6,7 as

You defined Pin 4,5,6,7 as motor pins but initialize Pin 6,7,8,9 as outputs. Something is wrong here.

thanks for reply

thanks for reply guys :slight_smile:

i forget to change the serial monitor to 19200 as it is specified in the sample code "Serial.begin(19200); //Set Baud Rate"

now my 4WD work fine…

To avoid those errors in the

To avoid those errors in the future, it’s a good idea to put a welcome message

Serial.println(“Hello”);

into the setup function.