Push button not working in Arduino Nano 33 IoT

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!

Problem, bread board power rail split:

a possible solution,

I thought my breadboard had a full power rail, since it doesn't have the gap that's shown in your pic?

Connect diagonally to the button.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.