DFRobotArduino Shields User Manual

Arduino Shields Manual
2010
- 7 -
Serial.begin(9600);
}
void loop()
{
int x,delay_en;
char val;
while(1)
{
val = Serial.read();
if(val!=-1)
{
switch(val)
{
case 'w'://Move ahead
Motor1(100,true); //You can change the speed, such
as Motor(50,true)
Motor2(100,true);
break;
case 'x'://move back
Motor1(100,false);
Motor2(100,false);
break;
case 'a'://turn left
Motor1(100,false);
Motor2(100,true);
break;
case 'd'://turn right
Motor1(100,true);
Motor2(100,false);
break;
case 's'://stop
Motor1(0,false);
Motor2(0,false);
break;
}
}
}
}