Putt Putt/Howard Community College/Spring2012/p501acm/Putt Putt/Arduino

REVISED MOTOR PARTY PROGRAM 1

// Adafruit Motor shield library // copyright Adafruit Industries LLC, 2009 // this code is public domain, enjoy! #include  #include    // DC motor on M2  AF_DCMotor motor(2); // DC hobby servo Servo servo1; // Stepper motor on M3+M4 48 steps per revolution AF_Stepper stepper(48, 2); void setup { Serial.begin(9600); // set up Serial library at 9600 bps Serial.println("Motor party!"); // turn on servo servo1.attach(9); // turn on motor #2 motor.setSpeed(200); motor.run(RELEASE); int i // Test the DC motor, stepper and servo ALL AT ONCE! void loop { motor.run(BACKWARD); for (i=0; i<255; i++) { servo1.write(i); motor.setSpeed(i); stepper.step(1, FORWARD, INTERLEAVE); delay(0); }   for (i=255; i!=0; i--) { servo1.write(i-255); motor.setSpeed(i); stepper.step(1, FORWARD, INTERLEAVE); delay(8); }   motor.run(FORWARD); for (i=0; i<255; i++) { servo1.write(i); motor.setSpeed(i); delay(0); stepper.step(1, FORWARD, DOUBLE); }   for (i=255; i!=0; i--) { servo1.write(i-255); motor.setSpeed(i); stepper.step(1, FORWARD, DOUBLE); delay(8); } }