Blinking LED circuit is a simple circuit which is made for flashing LED lights in specific pattern like the digital screen to make an image or text.
It also is made with a random blinking pattern for Christmas decoration lamp. Its main purpose is to make some LEDs blinking.
LED stands for Light Emitting Diode. It is one-of-many diode types in power electronic. It can act as a diode to hold current from flowing in the opposite direction and allows current flowing from the desired direction.
There are several ways to flash LED lights such as using a simple relay, Schmitt Trigger Inverter, various logic gate, microcontroller, transistor, or even transistor combined with a microcontroller.
For this time, we will focus on most common and most effective methods, including relay, transistor, microcontroller, and a microcontroller with a transistor.
Unlike common diode, LED emits light when forward current is passing through until the forward current stop flowing. LED has minimum current to be operated depends on its size, and it also has current threshold before it broke when the forward current is too high.
Relay is a basic electromagnetic device mainly used for automatic switching. The relay can turn on or off large current with an only small current.
Its primary parts are the electromagnetic part (the wire coil as a temporary magnet) and contact which looks like a lever with spring to pull it back.
The simplest explanation is, when the coil is energized by a small portion of current, it acts like a magnet and pulling the contact to it.
When the coil is not energized anymore, the magnetic force disappears and the spring pulls back the contact.
The use of a simple relay can be seen in Fig.2 where we use a relay, a resistor, a dc source battery, and a LED.
|Fig.2 LED is turned off and coil is energized|
The circuit above is the initial condition where the coil has not been energized by the battery.
|Fig.3 LED is turned ON and coil is not energized|
The circuit above is the condition where the coil has been energized and pulling the contact then delivers the current to a single LED.
After the contact moves the current to the LED, the coil does not get energized and the circuit’s condition is coming back to initial condition in Fig.2 and the cycle keeps looping shown in Fig.4.
|Fig.4 Blinking LED simple circuit with relay|
If the LED transition is too fast, you can use time delay consisting of a resistor and a capacitor to delay the transition with a charging capacitor principle as shown in Fig.5.
|Fig.5 Blinking LED with time-delay relay|
We can utilize transistor as a switch when we operate it on its active and cut-off region. This time we will use npn transistor to make LED flashing in sequence. Before we move on to the example, make sure you already understand how transistor work.
For the simplest example, let us see Fig.6 where we use a single resistor, a LED, a resistor, and a dc voltage source.
|Fig.6 Simple example of LED controlled transistor|
When the current flowing to the base terminal of the transistor, current from the collector side will flow to the emitter side and lighting the LED.
The base current needs to be higher than its minimum requirement, and the voltage will drop by approximately 0.7 V across the LED. The LED will emit its light as drawn in Fig.7.
|Fig.7 LED emits light|
Now let us try to use two LED flashing in sequence using two capacitor and two LEDs in Fig.8.
|Fig.8 Blinking LED with transistor|
The circuit in Fig.9 below shows us the first part of the cycle. At first, the transistor Q1 (the left side transistor) will run first and lighting the LED1 with full current supplied by a voltage source.
The current will flow through LED1, resistor R1 (most left resistor), and collector-emitter terminal of transistor Q1.
|Fig.9 The LED1 flashed|
The next part is shown in Fig.10 below, there will be flowing current through LED2, resistor R4 (top right resistor), and charges the capacitor C2 (right side capacitor) until full.
This occurs at a time slightly after the first LED flashed.
|Fig.10 Capacitor C2 is charged|
For some quiet time, the base-emitter voltage VBE will be lower than 0.7 V, as a result, LED1 goes out after the Q1 turns off.
The next part is Q2 start turning ON and the LED2 become brighter like in Fig.11.
|Fig.11 The LED2 grows brighter|
Like LED1 cycle, at the same time LED2 grows brighter, C1 will be charged until full until Q2 turns off and LED2 goes out when VBE is lower than 0.7 V.
|Fig.12 Capacitor C1 is charged|
And the cycle repeats from Fig.9
We can observer the full cycle in Fig.13 below.
|Fig.13 Blinking LED with transistors|
The microcontroller may be the easiest and most effective way to control LED blinking. It provides some unique patterns you can imagine along with controlling its switching blinking pattern interval time.
For this time, we will use the basic ATMEGA8535 to blink 8 LED in some pattern with the easiest method.
Below in Figure.(14) we provide an example with simple ATMEGA8535 with 8 LEDs along with their resistors.
|Fig.14 ATMEGA8535 and blinking LED|
For the most right to most left, we give the LEDs name D0 to D7 respectively. We will use PORT.A as output to deliver voltage at 5 V to the desired LEDs to make them flash.
In order to control the LED, we will need a basic idea about the biner number for programming.
PORT.A has 8 ports as output, so the biner code will be :
PORT.A = 0bxxxxxxxx;
where the x can be changed to 0 or 1.
Change x to 1 results in the connected LED flashing.
Change x to 0 results in the connected LED goes out.
In order to track which ports we need to program, let us see Fig.15 below.
|Fig.15 Microcontroller and LED|
From Fig.14 we realize that PORTA.0 (PA0) is connected with LED1 (D0), PORTA.1 (PA1) is connected with LED2(D1), and so on.
The biner code PORTA = 0bxxxxxxxx represents ports A7, A6, …. and A0 respectively.
Assume we want to light LED D0 which connected to A0 then we make a program line such as :
where we turn off D1 up to D7 and only turn on D0.
If we want to make LED flashing in an on-off pattern like in Fig.16,
|Fig.16 Flashing LED in order|
we write the biner code
In an opposite pattern like in Fig.17,
|Fig.17 Flashing LED in opposite pattern|
we can rewrite the code becomes :
For the last example, let us combine those two patterns into 1 continuous pattern like in Fig.18.
|Fig.18 Blinking LED with microcontroller|
And the code will be :
where we add ‘delay_ms(100)’ as pattern switching interval time 100 milisecond. We also use ‘while(1)’ for loop command.
Sometimes we use this method for a special case such as bigger LED which requires bigger current.
As we know already, most of the microcontroller only provides 5 V output voltage.
In order to flash a bigger LED, we need bigger output voltage. In this case, we can use npn transistor connected with an external voltage source and LED as shown in Figure.(19) below,
|Fig.19 Blinking LED with transistor-controlled microcontroller|
The program sequence will be the same as the previous example of microcontroller, we only need to add transistor and external voltage source.