Hi folks.
I am trying to program a robot to move straight, and then when it bumps into something like a wall, I want it to back up and turn around. Then continue moving straight.
I am familiar with RobotC but this is my first time trying to program with Arduino software and I'm pretty much lost.
Any help is much appreciated. I attached the program below... but I'll also copy/paste it here:
#include <ArduinoRobot.h>
int limitPin = 8;
int LmotorPin = 1;
int RmotorPin = 4;
void setup()
{
Robot.begin(); //initalizer
}
void loop()
{ if (digitalRead(limitPin) == 0)
{
Robot.motorsWrite(200, 200);
}
else
{
Robot.motorsWrite(-200, -200);
delay(2000);
Robot.motorsWrite(200, -200);
delay(2000);
}
}
Thanks!!
Angelina.ino (348 Bytes)