Hello everybody. I miss some basic electroncs here, so I'll appreciate any help.
I'm trying to control a two led signal with an Arduino structure. You can see the setup in the attached diagram. The idea is that when the pin 2 is put to GND (LOW) the signal switches from red to green by changing pins 4 and 7 ouputs in order to have a different current-flow direction.
While green is the only led on when I put 2 to GND, I get both leds on while pin 2 is left alone. Why?
Thank you for the answer. Pins are good (changed them after the diagram was drawn). With a pullup resistor the circuit works fine indeed (I knew it should be something basic, sorry! )
Thank you!
Much easier to connect the button between pin and ground, and use pull up in code (no resistor needed).
pinMode(BUTTON, INPUT_PULLUP);
Compressed code attached.
Leo..
You're welcome. I'm glad to hear it's working now!
Here's what I think was happening: Without a pull-up resistor, pin 2 was floating when the button was not connecting it to ground. When floating, a pin can flip back and forth from HIGH to LOW very quickly. If so, the LEDs were actually flashing on and off, but maybe so fast that they appeared to the eye to both be on at the same time.