Just because it's Christmas, I decided to do a small project with multi-colored LEDs to put at the entrance of my house, in the hallway.
It will use 5 LEDs of different colors and an ultrasonic sensor.
The goal is that every time someone passes in front of the sensor, a specific sequence of LEDs will light up.
The distance between the ultrasonic sensor and the wall is approximately 130cm.
I set it so that every time a person passes in front of the sensor and the distance is equal to or less than 90 cm, the LEDs are activated.
This circuit consists of 4 different sequences of flashing LEDs.
Three sequences are activated by the ultrasonic sensor, when a person passes in front of it. Pressing a push button allows switching from one sequence to another.
There's a second button that we can switch to sequence 4.
The sequence of 4 flashing LEDs does not use a sensor, it's for when we want the LEDs to flash without needing someone to walk in front of them. It's a typical Christmas light effect.
It's a very simple project made with an Arduino Uno and 5 LEDs of different colors. Blue, yellow, red, green, and white.
Calculating the resistance is crucial, as the voltage drops vary significantly between colors. Blue and green LEDs require more voltage than red and yellow, which affects the resistance calculation. Let's calculate the resistance value for each LED color.
The formula to be used is Ohm's Law adapted for LEDs:
\[ R = \frac{V_{out} - V_F}{I_F} \]
1. Red, Orange and Yellow
These LEDs have lower operating voltages (\(V_F\)).
Led´s String Lights For Christmas
Just because it's Christmas, I decided to do a small project with multi-colored LEDs to put at the entrance of my house, in the hallway.
It will use 5 LEDs of different colors and an ultrasonic sensor.
The goal is that every time someone passes in front of the sensor, a specific sequence of LEDs will light up.
The distance between the ultrasonic sensor and the wall is approximately 130cm.
I set it so that every time a person passes in front of the sensor and the distance is equal to or less than 90 cm, the LEDs are activated.
This circuit consists of 4 different sequences of flashing LEDs.
Three sequences are activated by the ultrasonic sensor, when a person passes in front of it. Pressing a push button allows switching from one sequence to another.
There's a second button that we can switch to sequence 4.
The sequence of 4 flashing LEDs does not use a sensor, it's for when we want the LEDs to flash without needing someone to walk in front of them. It's a typical Christmas light effect.
It's a very simple project made with an Arduino Uno and 5 LEDs of different colors. Blue, yellow, red, green, and white.
Calculating the resistance is crucial, as the voltage drops vary significantly between colors. Blue and green LEDs require more voltage than red and yellow, which affects the resistance calculation. Let's calculate the resistance value for each LED color.
The formula to be used is Ohm's Law adapted for LEDs:
1. Red, Orange and Yellow
These LEDs have lower operating voltages (\(V_F\)).
Red / Orange (\(V_F \approx 2.0\text{V}\)):
\[ R = \frac{5.0\text{V} - 2.0\text{V}}{0.020\text{A}} = \frac{3.0\text{V}}{0.020\text{A}} = 150\ \Omega \]Yellow (\(V_F \approx 2.1\text{V}\)):
\[ R = \frac{5.0\text{V} - 2.1\text{V}}{0.020\text{A}} = \frac{2.9\text{V}}{0.020\text{A}} = 145\ \Omega \rightarrow \text{Use } 150\ \Omega \]2. Blue, Green and White
High brightness LEDs that require more voltage to operate properly.
Blue (\(V_F \approx 3.5\text{V}\)):
\[ R = \frac{5.0\text{V} - 3.5\text{V}}{0.020\text{A}} = \frac{1.5\text{V}}{0.020\text{A}} = 75\ \Omega \rightarrow \text{Use } 68\ \Omega \text{ or } 82\ \Omega \]Green / White (\(V_F \approx 3.3\text{V}\)):
\[ R = \frac{5.0\text{V} - 3.3\text{V}}{0.020\text{A}} = \frac{1.7\text{V}}{0.020\text{A}} = 85\ \Omega \rightarrow \text{Use } 100\ \Omega \text{ or } 82\ \Omega \]General table:
Note: For Blue and Green LEDs, using slightly lower resistors (such as 68 \(\Omega\)) ensures maximum brightness in fast sequences.
Here is the schematic of the circuit:
Fig.1 - Schematic of the Christmas effect circuit.
Here's the Arduino code that you can use:
Fig.2 - Full Arduino code.
Here's a short video of all the LED flashing sequences, using my hand to simulate a person walking by.
Fig.3 - General video of the christmas circuit.
Leave A Comment