All exercises
2. Button control
Light the LED while the button on D2 is pressed.
Task
- 1.Run the program and press “Hold the button”.
- 2.Note that with INPUT_PULLUP the pin reads LOW while the button is pressed.
- 3.Write a program that toggles the LED on each press.
Code
Tab inserts two spaces. To leave the editor press Esc, then Tab.
Virtual stand
Program not started
| Pin | Part | State |
|---|---|---|
| D2 | Button | released |
| D13 | On-board LED (L) | off |
Serial monitor 9600
The program has not sent anything over Serial yet.