Forum >Problem with romeo example
General

Problem with romeo example

userHead zul88 2011-09-22 08:33:01 4367 Views2 Replies
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();
}

[img]
2011-09-23 01:51:07 hi bro [color=red]Hector[/color] ;)

thanks for reply..yes,its working now. ** for you!  ;D
userHeadPic zul88
2011-09-22 19:15:35 Hi Zul88,

With the code you are using you need to open a serial terminal. You can use the Arduino IDE.The last icon on the right is the "serial monitor"

Click on it and ensure the speed on the bottom right is: 19200, as it is specified in the sample code. Once in the serial terminal you can press "w" forward, "a" left, "d" right, and "s" back.

I have looked at your connections and it seems that everything is in order.

If you still can't get it to work, please post back.

Hector
userHeadPic Hector