/* * ChickenDoor.cpp Part 4 * * Created on: Jan 28, 2013 * Author: John */ /* * Oh no, where did most of the code go!! */ /* * Much is gone because this is a "Unit Test" phase */ /* * Lets make just one piece of it work, the motors */ const int motorPin=12, spinner=3; void setup() { pinMode(motorPin, OUTPUT); pinMode(brakePin, OUTPUT); } /************************** Motor Start and Stop ***********************************/ const int motorFWD=HIGH, motorRVRS=LOW, motorFAST=255, motorSTOP=0; const int brakeON=HIGH, brakeOff=LOW; void startMotorOpening() { Serial.println("Starting Motor-Open phase"); //claxonStart(); //brakeOff(); //motorStart(); // or maybe just for now digitalWrite( motorPin, motorFWD); // remove the comments; say it in the CODE digitalWrite( brakePin, brakeOff); analogWrite( spinner, motorFAST); } void startMotorClosing(){ // Hey this is STILL easy Serial.println("Starting Motor-Close phase"); digitalWrite( motorPin, motorRVRS); digitalWrite( brakePin, brakeOff); analogWrite( spinner, motorFAST); } void stopMotor(){ Serial.println("Stopping Motor"); analogWrite( spinner, motorSTOP); digitalWrite( brakePin, brakeOn); } void loop(){ /* Don't ever do this: * Don't ever use delay(). * This is cr*p. This is garbage. * So why am I doing it here? */ startMotorOpening(); delay(5000); startMotorClosing(); delay(5000); stopMotor(); delay(5000); } /* * */