User Guide
Sample Code
WhenconnectedtoanArduinomicrocontroller,theDFRobotShopRoverShieldaddsthebasic
hardwareneededtorunasmallmobilerobot.Weofferbasicsoftwareexamplesbelowtohelp
getyoustartedinprogrammingmobilerobotsandArduino.Thecodebelowisnot“optimized”
butisintendedtogetyoustartedwitheachofthemainfeaturesoftheshield.
Sketch #1: Basic Rover – Full speed forward
ThecodebelowwillcausebothmotorsconnectedtotheonboardHbridgetorotateatfullspeed.
/*CopyandpastethecodebelowintotheArduinosoftware*/
intE1=6;//M1SpeedControl
intE2=5;//M2SpeedControl
intM1=8;//M1DirectionControl
intM2=7;//M2DirectionControl
voidsetup()
{
inti;
for(i=5;i<=8;i++)
pinMode(i,OUTPUT);
Serial.begin(9600);
}
voidloop()
{
intleftspeed=255;//255ismaximumspeed
intrightspeed=255;
analogWrite(E1,255);
digitalWrite(M1,LOW);
analogWrite(E2,255);
digitalWrite(M2,LOW);
delay(100);
}
RobotShopInc.www.RobotShop.com