New guy here, so first things first. Hello!
I picked up a Arduino Uno yesterday. So far I've been having a lot of fun messing around, trying to get feel for the basics. I didn't suspect it would be so addicting.
I'm trying to make a small led light show for my first project but I'm having problems with digitalRead. The layout is very basic right now as I'm trying to plan. So I have two separate circuits. The button circuit from 5v to GND, which is the input when pressed. The other circuit is a simple led (pin 13, resistor, GND).
The Serial Monitor is displaying 1's & 0's randomly when the button is off resulting in a low flicker of the led. Then all 1's when it is pressed, which is correct.
In all honestly, I don't know if this is a programming or hardware issue. I've been trying different arithmetic to make it all 0's/off but to no avail (= 0 LOW, = 1 HIGH). If you have any suggestions they would be much appreciated.
int led = 13;
int in = 2;
int state = digitalRead(in);
if (state > 0)
else (state < 0);