Chaser de LED baseado em Arduino com 13 padrões de iluminação diferentes

Arduino-based LED chaser with 13 different lighting patterns

An LED chaser or sequencer is a popular LED driver circuit. It is used in running light string displays to flash different lighting patterns. In a chaser or sequencer circuit, a controller commands the sequence and timing of flashing LEDs to illuminate different types of lighting patterns.

This LED chaser is built on Arduino UNO . Arduino is currently the most popular single-board microcontroller. In this sequencer, seven LEDs interface with the Arduino to demonstrate 13 different lighting patterns.

In fact, it is possible to design an LED chaser with multiple LEDs using shift registers. In this LED chaser, the LEDs are directly interfaced with the Arduino pins, as the Arduino's GPIO can generate direct voltage and current required to turn them on/off.

The LEDs are controlled through the Arduino digital output . The UNO is programmed to output logic signals with different sequences on its pins with the appropriate timing pattern to show different LED light patterns.

Required components

1. Arduino UNO x1
2. LEDx7
3. 330 Ohm Resistor x7
4. Test board x1
5. Male to Male Jumper Wires

Circuit Connections
The circuit of this LED chaser is prototyped on a breadboard. The LEDs interface with the Arduino channels so that the channels absorb current from the LEDs. (To learn more about interfacing LEDs with Arduino, check out the LED Interfacing Tutorial ).

Here are the instructions to correctly assemble the circuit:

1. Connect the cathodes of the LEDs to the digital I/O pins 0, 1, 2, 3, 5, 6 and 7 of the Arduino UNO through the current limiting series resistor on each channel.

2. Connect the anode of all LEDs to the breadboard power line.

3. Load the LED Chaser sketch into Arduino.

4. Use the 5V power pin and one of the Arduino ground pins to supply 5V DC, then ground the breadboard.

5. Turn ON the Arduino UNO by supplying power from a USB or battery.

Circuit Diagram



How the circuit works
Light-emitting diodes (LEDs) are semiconductor diodes that emit light in a forward-bias condition. These diodes are similar to the signal diodes that are working.

LEDs are differentiated by the range of wavelengths they emit. According to the bandwidth of the emitted light, they require different forward voltages for polarization. The forward operating voltage for most LEDs ranges from 1.2 to 3.6 V, depending on the color.

Just like signal diodes, LEDs are also current-controlled devices and require between 12 to 30 mA for maximum illumination. For normal lighting, LEDs typically draw 5 mA of current.

The Arduino GPIO can supply or absorb up to 40 mA of current. The voltage output from the Arduino digital I/O channels is 5 and 3.3 V for logic HIGH on 5 and 3.3 V boards. The voltage level for logic LOW is 0V on both types of boards. The pins can sink the same voltage levels when configured as input. Thus, the LEDs can be driven directly through the Arduino I/O channels.

LEDs are two-terminal devices. This means that they can be interconnected in a circuit in two ways. In a way, a device (like the Arduino channel) supplies current to the LED. In this interfacing method, the cathode of the LED is connected to ground while the anode is connected to the current source.

In the second method, the device absorbs the current through the LED. In this interfacing method, the anode of the LED is connected to the DC power supply bus and the cathode is connected to the current sink.

However, there must be a series resistor connected to the LED in both cases to protect the LED from overcurrent.

When direct current is supplied or dissipated through the LED, it turns on and starts glowing. Forward current flows through the LED when it is configured for forward bias by applying the appropriate voltage. When forward voltage drops or reverse voltage is applied to an LED, it turns off and stops glowing.

In this circuit, seven LEDs are connected to channels 0, 1, 2, 3, 5, 6 and 7 of the Arduino UNO so that the pins must absorb the current through the LEDs. Red LEDs are used in the circuit that requires a direct operating voltage between 1.6 to 2V.

330 ohm resistors are also connected to each LED in the series. With this value of a resistor in series on each pin, the Arduino channels should absorb 9 to 11 mA of current when the LEDs are forward biased. (To learn more about interfacing LEDs with Arduino, check out the LED Interfacing Tutorial ).

Remember that the chaser or sequencer is an LED driver circuit that operates LEDs based on a predetermined sequence and schedule. In this LED driver circuit, the controller (Arduino UNO) is programmed to flash 13 different lighting patterns. In the first lighting pattern, the LEDs are turned on one after the other (from left to right) and then turned off one after the other (also from left to right).

A 300 millisecond delay is used when turning on each LED and a 200 millisecond delay is used when turning them off.

In the second lighting pattern, the LEDs are turned on one after the other (from right to left) and then turned off one after the other (from right to left).

A 300 millisecond delay is used to turn each LED on and a 200 millisecond delay is used to turn them off.

In the third lighting pattern, the odd-numbered LEDs are lit while the even-numbered LEDs are turned off. Then the even LEDs are turned on and the odd LEDs are turned off.

This pattern is repeated eight times before all LEDs turn off. A 300 millisecond delay is used between each sequence.

In the fourth lighting pattern, the LEDs are turned on one after the other (from left to right) and then turned off one after the other (from right to left).

A 300 millisecond delay is used to turn each LED on and a 200 millisecond delay is used to turn them off.

In the fifth lighting pattern, the LEDs are turned on one after the other (from right to left) and then turned off one after the other (from left to right).

A 300 millisecond delay is used to turn each LED on and a 200 millisecond delay is used to turn them off.

In the sixth lighting pattern, an LED on both sides is lit one after the other so that it slowly lights towards the center of the light shaft. Then it is turned off on both sides, disappearing into the center of the light string. This pattern is repeated five times and a 100 millisecond delay is used between each sequence.

In the seventh lighting pattern, the LEDs are turned on (from left to right) so that the light moves to the right of the light string, one LED by one LED. After the light cord is fully illuminated, the LEDs will turn off (from left to right) one after the other.

A 100 millisecond delay is used between each sequence when lighting the string, while a 200 millisecond delay is used between each sequence when the lights are turning off.

In the eighth lighting pattern, the LEDs are turned on (right to left) so that the light moves from the left of the light string, one LED by one LED. After the light cord is fully illuminated, the LEDs will turn off (from right to left) one after another.

A 100 millisecond delay is used between each sequence when lighting the string, while a 200 millisecond delay is used between each sequence when the lights are turning off.

In the ninth lighting pattern, the LEDs are turned on from the center and then towards both ends. Once the light cord is fully illuminated, the LEDs will turn off from the center to both ends, disappearing simultaneously on the left and right sides.

This pattern is repeated five times with a 100 millisecond delay between each sequence.

In the 10th lighting pattern, the LEDs are turned on (from left to right) so that the light moves from the right of the light string, one LED by one LED. After the light cord is fully illuminated, the LEDs will turn off (from right to left) one after another.

A 100 millisecond delay is used between each sequence when lighting the string, while a 200 millisecond delay is used between each sequence when the lights are turning off.

In the 11th lighting pattern, the LEDs are turned on (right to left) so that the light moves to the left of the light string, one LED by one LED. After the light cord is fully illuminated, the LEDs will turn off (from left to right) one after another.

A 100 millisecond delay is used between each sequence when lighting the string, while a 200 millisecond delay is used between each sequence when the lights are turning off.

Lighting pattern six is ​​repeated five times before lighting the 12th pattern. In the 12th lighting pattern, the LEDs are turned on (from left to right) so that the light moves to the right of the light string, one LED by one LED. After the light cord is fully illuminated, the LEDs will turn off (from left to right) so that the light disappears from the right of the light cord one by one.

A 200 millisecond delay is used between each sequence.

In the 13th lighting pattern, the LEDs are turned on (right to left) so that the light moves to the left of the light string, one LED by one LED. After the light cord is fully illuminated, the LEDs will turn off (from right to left) so that the light dims from the left of the light cord one by one.

A 200 millisecond delay is used between each sequence.

Finally, the ninth lighting pattern is repeated five times. The Arduino will keep repeating all the lighting patterns an infinite number of times until it is turned on. Whenever it is reset or the power is reset, it will start from the first lighting pattern.

Programming Guide

The LEDs interface with the Arduino pins so that the pins must absorb current to forward bias them. Pins are configured as output using the pinMode function within the setup function. The setup function is executed once when the Arduino is initialized.

empty configuration {
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
}

When a logic LOW is set as a pin output, current passes through the interface LED and it glows. When a logic HIGH is set to output a pin, the interface LED is deprived of the required forward voltage and will stop glowing.

The LEDs are connected to the Arduino UNO in this way:

When writing logical LOW or HIGH to the Arduino I/O channels, the digitalWrite function is used. To provide a delay between each sequence, the delay function is used.

For example, the first lighting pattern is displayed by running the following code snippet:

//Pattern 01
digitalWrite(0, DOWN);
delay(300);
digitalWrite(1, DOWN);
delay(300);
digitalWrite(2, DOWN);
delay(300);
digitalWrite(3, DOWN);
delay(300);
digitalWrite(5, DOWN);
delay(300);
digitalWrite(6, DOWN);
delay(300);
digitalWrite(7, DOWN);
delay(300);

digitalWrite(0, HIGH);
delay(200);
digitalWrite(1, HIGH);
delay(200);
digitalWrite(2, HIGH);
delay(200);
digitalWrite(3, HIGH);
delay(200);
digitalWrite(5, HIGH);
delay(200);
digitalWrite(6, HIGH);
delay(200);
digitalWrite(7, HIGH);
delay(200);

The code for all lighting patterns is written in the loop function. This code keeps repeating itself an infinite number of times, iterating through each lighting pattern until the Arduino stays on.

Whenever the Arduino is restarted or restarted after a shutdown, the code will be started from the setup function. The full sketch of this Arduino-based LED chaser appears below the video.

Demo video:

Back to the blog

Leave a comment

Comments need to be approved before publication.