Starting Electronics Needs Your Help!
It is that time of the year when we need to pay for web hosting and buy new components and equipment for new tutorials. You can help by making a donation. Contribute to this website by clicking the Donate button. The total will be updated once daily. (You may need to clear your browser cache to see the updates.)
Target Amount: $2000
Amount Raised: $289
Created on: 2 August 2012
A switch (push button) is connected to the Arduino. When the switch is closed, the LED switches on, when the switch is opened, the LED switches off.
Similar to the DigitalReadSerial project (project 2), but instead of sending the state of the switch to the serial monitor, the state of the switch is displayed on an LED. The Arduino on-board LED is used so no external LED is necessary.
File → Examples → 2.Digital → Button
Connect the switch to the Arduino as done in project 2 (DigitalReadSerial), or see the connection diagram for the Button project on the Arduino website.
In the Arduino IDE, select File → Examples → 2.Digital → Button to open the Button sketch. Verify and upload the sketch.
Closing the switch that is connected to Arduino pin 2 will switch the on-board "L" LED on the Arduino board on. Opening the switch will switch the LED off again.
Can't see the video? View on YouTube →