I am experiencing some strange behavior which I would like some help to understand.
I am playing around with reading the input from a button, but as the button does not perfectly fit into my prototype board it sometimes falls out. When it does, the state of the pin its connected to changes from HIGH to LOW, and back again for an indefinite amount of time, but only if im also writing a serial message. For it to happen, the wire needs to be plugged into the board, but not to anything on the other side (so the problem is not the button popping in an out, the problem can be replicated without the button)
To make it even more strange, it only happens when i have my hands close to the board!
Please see the attach photos.
// Configure the board
boolean buttonPressed = false;
if(digitalRead(4) == LOW)
buttonPressed = true;
Serial.println("button NOT pressed");