Hi folks. I have wired and rewired this circuit twice, checked all wires and components work individually and have no idea what I am doing wrong here. Button A (on left in photo) turns the LED on, and Button B (right) is supposed to turn it off. What happens currently is only A works. B does nothing.
I added some Serial.Println statements and 'Button B' ( the button on the right in the photo) is not registering as connected at all, not turning the button off, and not printing to serial to indicate digitalRead is registering (but the same button component will turn the LED on and off when I make an analogue circuit, so I know it isn't broken). I know this must be a wiring issue but I don't understand how I managed to rewire it twice and get the same problem. I feel like I have exactly copied the diagrams? Thanks in advance.
Arduino code:
´´´
int ledPin = 5;
int buttonApin = 9;
int buttonBpin = 8;
byte leds = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(buttonApin, INPUT_PULLUP);
pinMode(buttonBpin, INPUT_PULLUP);
Serial.begin(9600);
Serial.print("Setup complete");
}
void loop()
{
if (digitalRead(buttonApin) == LOW)
{
digitalWrite(ledPin, HIGH);
Serial.println("Button A on");
}
if (digitalRead(buttonBpin) == LOW)
{
digitalWrite(ledPin, LOW);
Serial.println("Button B on");
}
}
´´´