/*this works with both motors turning in unison, with the positive of each motor on the chip end of the motor connectors. * pin 12 goes to IN1, pin 8 goes to IN3. pin 12 & 8 are FORWARD when high and 9 & 13 LOW. * see hookup image in lesson, I have the RIGHT motor going to MOTOR B */ void setup() { // put your setup code here, to run once: pinMode (13, OUTPUT); // setup our control pins as outputs. pinMode (12, OUTPUT); pinMode (11, OUTPUT); pinMode (10, OUTPUT); pinMode (9, OUTPUT); pinMode (8, OUTPUT); } void loop() { // put your main code here, to run repeatedly: //**start off with the first straight leg of the figure 8 digitalWrite (12, HIGH); //set both right and left motors for forward rotation digitalWrite (13, LOW); //we only do this once because we will never reverse a motor in this sketch. digitalWrite (8, HIGH); // we will simply turn by varying the speeds of the two motors digitalWrite (9, LOW); //drive forward on PWM, attempt a straight line for half a second analogWrite (11, 125); analogWrite (10, 125); delay (500); //alter this delay time to change the distance traveled on your straight leg //first right turn in the figure 8, slow down motor "B" analogWrite (11, 125); analogWrite (10, 20); delay (2500); //alter this delay time to change how far the robot turns on the right turn //second straight leg, attempt a straight line for half a second analogWrite (11, 125); analogWrite (10, 125); delay (500); //alter this delay time to change the distance traveled on your straight leg //left turn to complete the figure 8, slow down motor "A" analogWrite (11, 20); analogWrite (10, 125); delay (2500); //alter this delay time to change how far the robot turns on the left turn //now loop back to the first straight leg of the figure 8 }