Hey everyone, I have just gotten into arduino and instantly wasted about 30 mins trying to get a button to work. Please help, even after pressing the button and internally pulling up the button, the button still logs 1 when pressed.
This is my code:
void setup() {
// put your setup code here, to run once:
pinMode(2, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int btn1 = digitalRead(2);
Serial.println(String(btn1));
}
The pair of pins on 2 edges of the button are connected together and the switch contacts are between each pair. If you connect to 2 adjacent pins there is a 50/50 chance that they are already connected together but a diagonal pair will always have the contacts between them