Read buttons, limit switches, and contact sensors with stable internal pullups.
Open in compiler →Source code and build tools are available in the protected platform workspace.
How it works
Read a button or limit switch reliably using the internal pullup resistor.
- Wire one side of the switch to the input pin and the other side to GND.
- Enable INPUT_PULLUP so no external resistor is required.
- Treat LOW as pressed and HIGH as released.
- Mirror the state to D13 and Serial Monitor.
Connections
| Pin | Connect to | Note |
|---|---|---|
| D7 | Push button or limit switch to GND | Pressed reads LOW because the internal pullup is enabled. |
| D13 | Built-in LED or indicator LED through resistor | D13 is safe for the onboard LED on most Arduino boards. |