The button doesn't work

It is difficult to see how your button is wired since it is a 4 pin version in your drawing. When using those types of buttons, it is best practice to wire one corner to ground and the other diagonal corner to an input pin. This avoid the problem of installing the button rotated 90 degrees since one side is tied together. You then declare the pin as INPUT_PULLUP so when not pressed, it reads HIGH and when pressed, it reads LOW.

I would suggest writing a separate test sketch that does nothing but read the button and print the results to the serial monitor. Get that working before building a bigger sketch.

2 Likes