Hi,
I'm having an issue where the input from a pin keeps changing between 1 and 0 even though I am not pushing the button. I've tried switching the wires and the button. Am I doing something wrong? or is something broken?
Thanks in advance,
I have it wired like this:
I'm running this code:
void setup() {
Serial.begin(9600);
pinMode(2, INPUT);
}
void loop() {
Serial.print(digitalRead(2));
delay(200);
}
I get this output:
1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000111111111111111111111111111111111111100000000000000000000000