/* Bluetooth Retracting Projector Screen This sketch controls the motor that rolls and unrolls the projector screen. Commands are sent from an android phone via Bluetooth to the Arduino. An analog pot monitors screen position and acts as an over-travel prevention switch. Created 17 Feb 2012 modified xx Xxx 20xx by Brett Russell */ #include // Define Constants AF_DCMotor motor(2, MOTOR12_1KHZ); //create motor on number 2 port, 1KHz pwm const int onDelay = 5000; // sets the amount of time the motor runs const int offDelay = 3000; // sets the amount of time the motor is off void setup() { // set motor speed, 250/255 motor.setSpeed (250); } void loop() { //turns the motor on forward motor.run(FORWARD); //runs for 5 seconds delay(onDelay); //turns the motor off motor.run(RELEASE); //stops for 3 seconds delay(offDelay); //runs the motor backwards motor.run(BACKWARD); //runs for 5 seconds delay(onDelay); //turns the motor off motor.run(RELEASE); //off for 3 seconds delay(offDelay); }