Hey there,
I can't seem to make my simple push button program work. All I get is the value 0, whether I'm pressing the button or not. Attached are the circuit I u
sed and the code. The brown cable is connected to D2 (the others are the ground and the 3.3 V), sorry for the poor cable management.
const int pinButton = 2;
void setup() {
pinMode(pinButton, INPUT);
Serial.begin(9600);
}
void loop() {
int stateButton = digitalRead(pinButton);
Serial.println(stateButton);
delay(20);
}
Do you know what's causing the problem? Thanks!