digitalRead/if error: runs through code, despite if's

drewtoby:
However, when I add a resistor the Arduino goes in a high to low, then low to high cycle, even when no current is being passed through. Without a resistor the arduino still does that, but is not as fast of cycles as with a resistor. :cold_sweat:

Is that resistor connected to 5V, GND, or just in series with the wire? It needs to "pull up" or "pull down" to a high or low.