r/arduino • • Oct 18 '26

Beginner's Project Third Project: Button controlled LED

Post image

I should’ve most likely made this before I did my DHT11 project, but today i decided to find out how buttons work as I need them for my first actual project - more on that soon 😉. This was pretty simple today, one thing that confused me was buttonState, for some reason I assumed HIGH meant the button had been pressed (as in the button was on, as LED’s use HIGH to switch on). After I figured that out it was smooth sailing.

Just wanted to thank this sub for helping me on my first post to come up with some fun projects I can use to learn more basics! I really appreciate it.

9 Upvotes

3 comments sorted by

2

u/CoffeeSalt2036 Oct 18 '26

wiring decides that, not the code. with INPUT_PULLUP the pin idles HIGH and reads LOW when pressed, so the logic flips. everyone hits this once.

1

u/gm310509 400K , 500K , 600K , 640K , 750K Oct 19 '26

... assuming it is wired up correctly.

Buttons and switches do seem to be somewhat confusing for newbies - especially if they have used them primarily to turn power on/off (which for newbies is a different circuit configuration compared to how you read a button/switch in a live system).

1

u/DavidFromArduino Arduino Staff Oct 19 '26

looking good! don't forget to debounce! 💙

https://docs.arduino.cc/built-in-examples/digital/Debounce/