Controlling an external LED with the GPIO
Nowadays, LEDs are everywhere, particularly in our houses, because they use less energy than older lights for the same luminous intensity. However, the LEDs considered for our experiments are not light bulbs but through-hole LEDs for rapid prototyping on the breadboard.
In this recipe, we will discover how to build a basic circuit with an external LED and program the GPIO peripheral to control its light.
Getting ready
To implement this recipe, we need to know how the LED can emit light and how to program the microcontroller GPIO peripheral to turn the light on and off.
Let’s start by explaining what an LED is and how it works.
Understanding the LED functionality
LED stands for Light Emitting Diode and is a semiconductor component that emits light when a current flows through it.
In this book, we will use through-hole LEDs, which are made of the following:
- A head of transparent material from where...