So I made a mini-game with my arduino uno. So there are 3 different colored LEDs, RED, YELLOW, AND green. When the green led is on and you press the pushbutton, you are given three points, yellow: you get 1.5 points and red, you get 0.5 points. And it will print your score at the end of the loop. But in the serial monitor, it just prints 0 each time. I don't know why so that's why I'm here.
I didn't send my void loop because I didn't put anything in it. Thanks!
My code:
Nothing, because I wired everything for the pushbutton correctly. On the bottom right leg, I added a pull-down resistor(1k ohm) to the ground. The bottom left leg of the pushbutton is connected to the 5 volt supply. Then the top right leg is connected to a digital pin
You can make a quick tester by putting a 220 Ohm resistor in series with one leg of a red LED. Then use the two unconnected ends to test for 5 volts. If the LED lights you have 5 volts, if it doesn't, you don't have 5 volts. Check the Arduino pin to ground and see if it shows light when the push button is pressed.
Ok thanks. So with a bit of printing, I figured out the problem, and it is that the pushbutton's state is always low. So how can I make the state high?