Read whether a button is pressed
Prints D2's state to the serial monitor as 0 or 1, over and over.
Input
buttonGPIO
Why this support circuit is added
Push button (pulls to GND).
Grounded in the catalog and golden patterns (real open-source circuits). Every auto-inserted part comes with a reason.
Using this part in a project adds the circuit below, each element with its reason.
Pull-up so the input is defined while the button is open.
Run them in the browser, no login needed.
Prints D2's state to the serial monitor as 0 or 1, over and over.
D13 lights only while the button is pressed.
Reads a button with INPUT_PULLUP and no external resistor — pressed reads 0.
A button bounces on contact; waiting 50 ms turns the noise into one press.
Detects the moment a button goes down, not whether it is down.
Stays inside the while-loop for as long as the button is down.
D13 lights up while the button is held. Start here.
Every press adds one, shown on a four-digit seven-segment display.
Pressing the button turns the NeoPixel ring blue and plays two tones.
The relay closes when the DS18B20 passes 28 °C; an ultrasonic sensor measures distance too.