/* This sketch simply drives the robot forward, then backward, attempting a straight line using PWM * This will reveal any inconsistencies between motor speeds as they should both turn at the same speed. * 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); 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: digitalWrite (12, HIGH); digitalWrite (13, LOW); digitalWrite (8, HIGH); digitalWrite (9, LOW); //turn on the motors for one second analogWrite (11, 125); analogWrite (10, 125); delay (1500); //turn off the motors for one-half second analogWrite (11, 0); analogWrite (10, 0); delay (1000); digitalWrite (12, LOW); digitalWrite (13, HIGH); digitalWrite (8, LOW); digitalWrite (9, HIGH); //turn on the motors for one second analogWrite (11, 125); analogWrite (10, 125); delay (1500); //turn off the motors for one-half second analogWrite (11, 0); analogWrite (10, 0); delay (1000); }