OR gate example with Tact switches does not work

// C++ code
//
void setup()
{
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, OUTPUT);
}

void loop()
{
if (digitalRead(2) == 1 || digitalRead(3) == 1) {
digitalWrite(4, HIGH);
} else {
digitalWrite(4, LOW);
}
delay(10); // Delay a little bit to improve simulation performance
}

I have the board setup like as shown on tinkercad

However when I set it up, it appears to give me a high on digital pin 4 all the time once a switch has been pushed and released.
If I try grounding pin 4, nothing works.

Any help most appreciated.

It is impossible to tell how your project is wired from your photograph. Please post a full schematic. I do not have a Tinkercad account and I am not going to set one up just to see your schematic

Have you got pulldown resistors in place on the inputs to keep them in a known state at all times ?

I watched your video. Your circuit is working perfectly. Good work. Only the polarity of the LED is not what is expected. You can wire the LED to be "on" or "off" with a HIGH output, depending on whether you connect the other end to ground or +5V.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.