Make Robot Move and turn

posted Mar 17, 2016, 12:47 PM by Tony Farley   [ updated Mar 18, 2016, 1:14 PM ]
  1. Make your robot move, turn, and move again. It should go in a box shaped path.
  2. Film your successful robot and put the video on your website. Be sure to write a few sentences about it.
  3. Alter the program to make the robot turn left,  then right, or do something else.  Film it and post the video, the program, and an explanation of what you did.

Here's the circuit:


Here's the program to run for #1

void setup() {
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
}

void loop() {
  digitalWrite(12, HIGH);   // turns the motors on
  digitalWrite(13, HIGH);  
  delay(1000);                   // wait for a second
  digitalWrite(12, LOW);    // turn the motors off
  digitalWrite(13, LOW);  
  delay(1000);                   // wait for a second
  digitalWrite(12, HIGH);   // turns one motor on to turn the robot
  digitalWrite(13, LOW); 
  delay(400);                       // only turn for two tenths of a second
  digitalWrite(12, HIGH);   // turns turns both motors on to go straight again
  digitalWrite(13, HIGH); 
}


Comments