0% found this document useful (0 votes)
19 views1 page

Manual 2

The document outlines motor control commands for a robot, including movement and obstacle detection functions. It provides example code for avoiding obstacles by reversing and turning when an object is detected. Additional resources and program files are referenced for further guidance on implementation.

Uploaded by

2fvzgpwrg7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Manual 2

The document outlines motor control commands for a robot, including movement and obstacle detection functions. It provides example code for avoiding obstacles by reversing and turning when an object is detected. Additional resources and program files are referenced for further guidance on implementation.

Uploaded by

2fvzgpwrg7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Motor control

ForwL; ForwR;
BackL; BackR;
StopL; StopR;
Stop;
Whiskers
ObsL ObsR
Loudspeaker and arduino led
SpOn; LedOn;
SpOff; LedOff;
SpToggle: LedToggle;

Examples:
ForwL; ForwR;
delay (1000); Stop;
Move for 1 second
if (ObsR | ObsL) {
SpOn; delayMicrosecond (500);
SpOff; delayMicrosecond (500);
}
Beep if against an bstacle

If you are not familiar with #defines and reference files, see www.didel.com/coursera/LC.pdf (in
french)
and www.didel.com/diduino/ArduinoInclude.pdf

All the programs can be found under www.didel.com/xbot/XbotBegin.zip


Program 1 – Avoid obstacles
When the robot touch an object or the walls, he has to back and turn significantly.
// AvoidObstacle1.ino
// Back and turn a little when an obstacle is found.
#include "XBotE.h"

void setup() { // initialisation


SetupXbotE();
}
#define DelRef 300 // back delay
#define DelRot 200 // rotate delay
void loop() {
ForwR; ForwL;
if (ObsR) { // back and turn
BackR; BackL; delay(DelRef) ;
StopR; delay(DelRot);
StopL;
}
if (ObsL) { //on recule et tourne
BackR; BackL; delay (DelRef);
StopL; delay(DelRot);
StopR;
}
}

Do not forget to save, and save under a new


name when you change the functionnality.

See www.didel.com/diduino/ArduinoInclude.pdf

You can use Arduino functions in the definition, It makes the program longer and slower,
but this is not a critical point. What is important is the program must refer to any robot with 2
motors and 2 whiskers.

You might also like