/*
29/01/2019
Written by: Gabby Shimoni
Description:
This program read two push buttons and print their state to serial monitor
*/
#define pb1Pin 9
#define pb2Pin 10
int pb1Value = 0;
int pb2Value = 0;
#define motor1Pin 5
#define motor2Pin 6
void setup() {
Serial.begin(9600);
pinMode(pb1Pin, INPUT);
pinMode(pb2Pin, INPUT);
pinMode(motor1Pin, OUTPUT);
pinMode(motor2Pin, OUTPUT);
}
void loop() {
pb1Value = digitalRead(pb1Pin);
pb2Value = digitalRead(pb2Pin);
if (pb1Value == HIGH && pb2Value == LOW) {
digitalWrite(motor1Pin, HIGH);
digitalWrite(motor1Pin, LOW);
}
if (pb1Value == LOW && pb2Value == HIGH) {
digitalWrite(motor1Pin, LOW);
digitalWrite(motor1Pin, HIGH);
}
if ((pb1Value ^ pb2Value) == LOW) {
digitalWrite(motor1Pin, LOW);
digitalWrite(motor1Pin, LOW);
}
}
Comments