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!

For an overview of several concepts used in these examples, check out the slideshow below.

Last updated

Was this helpful?