Digital Inputs
Let's control our LEDs with some pushbuttons!
In this lesson, you will learn to use push buttons with digital inputs to turn an LED on and off. Pressing the button nearer the top of the breadboard will turn the LED on, pressing the other button will turn the LED off.
Parts:
1 - 5mm red LED
1 - 220 ohm resistor
1 - push switches
1 – Assorted Wires
1 - Breadboard
1 - Elego Uno R3
Wiring Diagram:

Code:
If done right, your LED should turn on when you press the button and it should turn off when you let go of it.
After messing around with this one for a while, try the next one too!

Now your LED should flash when you hold down both buttons, stay of when you are holding down one button, and turn off if you let go of both buttons.
For an overview of several concepts used in these examples, check out the slideshow below.
Last updated
Was this helpful?