DC MOTOR CL 2

By Csjohnston

Update of the last Circiut upload

//00.00.02b 


 // Start buttons
const int buttonPin = 2;     // Forward button 
const int buttonPin1 = 4;  // Rev Motor
// Motor controls 
const int ledPin =  13;      // Forward Motor 
const int ledPin1 =  12;    // Rev Motor
// variables will change:
int buttonState = 0;         // variable for reading the pushbutton status
int buttonState1= 0;
void setup() {
  // initialize the Motor pin as an output:
  pinMode(ledPin, OUTPUT);
  pinMode(ledPin1, OUTPUT);      
  // initialize the pushbutton pins as an inputs
  pinMode(buttonPin, INPUT);
  pinMode(buttonPin1, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);  // Forward button
  buttonState1 = digitalRead(buttonPin1);  // Rev button
  // check if Forward button pushed
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    digitalWrite(ledPin, HIGH);   // Forward ON
  } 
  else {
  // Button not pushed 
    digitalWrite(ledPin, LOW); 
} 
   if (buttonState1 == HIGH) 
digitalWrite(ledPin1, HIGH);  // Rev ON 

  else {
    // turn Motor off:
     digitalWrite (ledPin1, LOW);
  }
}