I am having trouble to get the following output :
Both Switches Off > Green LED glows (pin 5)
Switch A On > Red LED glows (pin 3)
Switch B On > Red LED glows (pin 4)
I connected one more switch with pin 7 and added one 10K resistor as done in the original configuration.
The output is weird as only one of the Red LED glows and buttons don't work
Code:
int A = 0;
int B = 0;
void setup (){
pinMode (3,OUTPUT);
pinMode (4,OUTPUT);
pinMode (5,OUTPUT);
pinMode (2,INPUT);
pinMode (7,INPUT);
}
void loop (){
A = digitalRead(2);
B = digitalRead(7);
if ( A == LOW && B== LOW ){
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
}
else {
if (A == HIGH && B == LOW) {
digitalWrite(5, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
else {
digitalWrite(5, LOW);
digitalWrite(4, HIGH);
digitalWrite(3, LOW);
}
}
}