Skip to content
Emblem of the National Guard of the Republic of UzbekistanGUARDTECH
All exercises

2. Button control

Light the LED while the button on D2 is pressed.

Task

  1. 1.Run the program and press “Hold the button”.
  2. 2.Note that with INPUT_PULLUP the pin reads LOW while the button is pressed.
  3. 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 states
PinPartState
D2Buttonreleased
D13On-board LED (L)off

Serial monitor 9600

The program has not sent anything over Serial yet.