|
lm358 |
x 1 |
LED Fader - With or Without Arduino
Have an awesome project in mind using some LEDs. In that project I will be using some LED Fading Effect and few LED Chaser Circuits. But before jumping onto that, I thought I should create a short tutorial and show you guys how to fade a LED with or without an Arduino automatically or manually using a potentiometer.
Video: https://youtu.be/IIUsdICycOw
Without Arduino
Lets first create the fader circuit without an Arduino. The base of this circuit is an operational amplifier IC named LM358. In this circuit, initially, the LED slowly glows with increasing brightness & after reaching its maximum brightness, the LED slowly dims its brightness and the process continues.
Automatic Fading
Components Required
For the Non-Arduino bit we need:
1 x LM358 IC
1 x BC547 Transistor
1 x 0.47μF Capacitor
2 x 4.7KΩ Resistors
1 x 22KΩ Resistor
1 x 10KΩ Resistor
1 x 4.7MΩ Resistor
1 x 220Ω Resistor
1 x LED
and a 9V Battery
How This Circuit Works
To get the fading effect we need to generate a series of triangular waves.
Because of the triangular waves, the LED starts glowing slowly and then slowly dims off and the cycle continues.
This setup is done using the LM358 IC. LM358 is a dual operational amplifier (Op-Amp) IC, integrated with two op-amps powered by a common power supply. Pins 1, 2, and 3 are one op-amp channel, and pins 5, 6, and 7 are the 2nd op-amp channel.
As the capacitor charges and discharges the state of the PIN 3 switches from high to low and based on that the PIN 2 of the op-amp obtains the desire output. If you want to know more about this IC, please check out my "Tutorial No 21 : DIY - IR Module" : https://youtu.be/_M8FQIPi1qk.
So, basically the op-amp here is used for voltage level detection. In this circuit, we are applying a voltage on positive pin (PIN-3) and the voltage to be detected is applied at negative pin (PIN-2).
The transistor acts as a signal amplifier. You will need this if you are attaching a cluster of LEDs however for just 1 LED you can simply remove it.
The Board
So, this is how my board looks like in 2D and 3D.
There are 15 breakout-boards in this 100cm x 100cm assembly.
Component Assembly
Now, lets solder all the components to the board. Lets first solder all the resistances to the board. Then lets solder the transistor followed by the capacitor to the board. After that lets solder the LED and the female pin header. To conclude the setup, lets solder the IC base and then install the IC into it.
Demo
So, this is how it looks like.
Good thing about LEDs is that they can be easily controlled as compared to the traditional light bulbs. Which means you can easily change their intensity based on your need. Just by making a slight modification to this circuit you can change the brightness of a LED Lamp when someone walks in or out of a room.
Manual Fading Using PWM
Now, if you want to get the same dimming effect but want to manually control the intensity, you will have to find a way to modulate the pulse sent to the LED or group of LEDs using a potentiometer. I am going to do this by generating PWM Signals.
What is PWM?
Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means.
PWM value varies from 0 to 255. The bigger the value of PWM, the brighter the LED is and vice versa.
- If PWM = 0, it is same as GND, so the LED will be OFF
- If PWM = 255, it is same as VCC, so the LED will be fully ON
To get varying analog values, you change, or modulate, that pulse-width. If you repeat this on-off pattern fast enough with an LED, the result is as if the signal is a steady voltage between 0 and 5v controlling the brightness of the LED.
In this setup, we are going to use the 555 Timer IC in Astable mode (A free-running multivibrator that has NO stable states but switches continuously between two states this action produces a train of square wave pulses at a fixed known frequency) to generate the PWM Signals. 555 Timer IC will vary the voltage delivered to the LEDs to achieve the Dimming effect of the LED.
Components Required
For this setup we need:
1 x 555 Timer IC
1 x LED
1 x 220Ω Resistor
2 x 1N4007 Diodes
1 x 50KΩ Potentiometer
1 x 10nF Capacitor
1 x 100nF Capacitor
and a 5V Battery
How This Circuit Works
Based on the charging and discharging timings of the Capacitor, a PWM Signal is generated at PIN 3 (OUT PIN) of the 555 Timer IC. The output is then sent to the LED to produce the dimming effect.
Demo
So, this is how it looks like.
By rotating the knob of the 10K Pot we can adjust the brightness of the connected LED.
With Arduino
Now, lets repeat these setups using an Arduino. The beauty of Arduino is that it has 6 digital pins that can be used as PWM outputs (3, 5, 6, 9, 10, and 11). PWM signals are sent using the analogWrite() function by passing a value between 0 - 255.
- analogWrite(255) requests a 100% duty cycle (always on),
- and analogWrite(127) is a 50% duty cycle (on half the time), and so on.
Components Required
For this setup we need:
Arduino UNO/Nano whatever is handy
1 x Breadboard
1 x LED
1 x 220Ω Resistor
1 x 10KΩ Potentiometer
Automatic Fading
Connect the positive leg of your LED to the digital output PIN9 of your Arduino through a 220Ω resistor. Connect the negative leg directly to the GND. That it, that's how simple it is.
The Code
After declaring PIN 9 as LedPin, and setting up the pinMode in the setup() section, we are going to loop through and dim the LED in the loop section.
By gradually increasing the PWM value from 0 to 255, and then back to 0 we can get the fading effect. In this sketch, the PWM value is set using a variable called 'brightness'. Each time in the loop, it increases by the value of the variable 'fadeAmount'.
If brightness is at either extreme of its value (either 0 or 255), then 'fadeAmount' is changed to its negative. So, if the fadeAmount is 5, then it is set to -5 and if it is -5, then it is set to 5. The next time through the loop, this change causes brightness to change its direction. A delay is added to control the speed of the fading effect.
Demo
So, this is how it looks like.
Manual Fading
Connect the positive leg of your LED to the digital output PIN6 of your Arduino through a 220Ω resistor. Connect the negative leg directly to the GND. Connect the left (or right) pin of the 50KΩ PoT to VCC and then connect the right (or left) pin of the PoT to the GND. Now, connect the 'data' pin of your potentiometer to the Analog PIN 'A0' of the Arduino.
In this circuit, the potentiometer is working as a voltage divider. One of the outer pins is connected to the GND, the other to Vcc and the middle pin is the voltage output. The wiper position in this setup determines the output voltage.
Now, lets have a look at the code.
The Code
Based on my setup, I set the LedPin as 6 and Potentiometer pin Pot as A0. Another variable 'Knob' is used to read and store the value of the potentiometer.
pinMode of the LedPin is set to OUTPUT and we don't need to do anything for the PoT as its default value is already set as input.
In the 'loop()' section I am first reading the value of the PoT using the 'analogRead()' function and then mapping its value between 1 to 255. A potentiometer intakes a value between 1 and 1024, but in our setup it has to be between 1 to 255. The 'map()' function divides the value read from the potentiometer into equal intervals of 1/255, which is then sent to the LED using the 'analogWrite()' function.
Demo
So, this is how it looks like.
Thanks
Thanks again for checking my post. I hope it helps you.
If you want to support me subscribe to my YouTube Channel: https://www.youtube.com/user/tarantula3
Full Blog Post: https://diy-projects4u.blogspot.com/2021/02/led-fader-with-or-without-arduino.html
Video: https://youtu.be/IIUsdICycOw
Gerber File:
1. Gerber : https://drive.google.com/file/d/1w1hHZBFsXQR74ZTn04097awaAUqMndJi/view?usp=sharing
The Code:
1. Automatic Fading : https://drive.google.com/file/d/1hab3sISIlurrPQBat80OLb90RXqQKzLZ/view?usp=sharing
2. Manual Fading Using PoT : https://drive.google.com/file/d/1TzXdVO5lVjPNaw_NPSUexIye3WZGJ6cj/view?usp=sharing
Sketches: https://drive.google.com/file/d/1_WtmESof7kSyuJ_cmkkFZ8E8mdQXl3Z9/view?usp=sharing
BTC: 1M1PdxVxSTPLoMK91XnvEPksVuAa4J4dDp
LTC: MQFkVkWimYngMwp5SMuSbMP4ADStjysstm
DOGE: DDe7Fws24zf7acZevoT8uERnmisiHwR5st
ETH: 0x939aa4e13ecb4b46663c8017986abc0d204cde60
BAT: 0x939aa4e13ecb4b46663c8017986abc0d204cde60
LBC: bZ8ANEJFsd2MNFfpoxBhtFNPboh7PmD7M2
Thanks, ca again in my next tutorial.
LED Fader - With or Without Arduino
- Comments(0)
- Likes(0)
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Ashish Adhikari
- Cute Medusa 3D Printed Humidifier Humidifiers add moisture to the air. They can help people with dry skin, allergies, and respiratory ...
- 4x4x4 PCB LED CUBE Note from PCBWay: This project includes two PCBs, if both need to be produced, please inform your sa...
- Getting Started With Raspberry Pi Pico Couple of months ago, I bought a "Raspberry Pi Pico" to get some hands-on experience of it and to cr...
- Destiny Internet Ghost - Internet Notifier The Internet has changed the way we live our lives. From communication, education, banking, entertai...
- Liquid level indicator Using ULN2003 A water level indicator detects and indicates the level of water in an overhead tank and relays the ...
- All About IC UNL2003 The UNL2003 IC contains 7 High Voltage, High Current NPN Darlington Transistor Arrays each rated at ...
- NodeMCU Based: 3D Printed Indoor Gauge Thermometer Had some time this weekend and a desire to create something new and interesting, so went ahead and c...
- Rechargeable Gothic Lantern A Gothic Lantern is a captivating piece of lighting that brings the allure of the Victorian Era into...
- 555 Adjustable Delay On Off Timer Circuit The 555 timer IC is an integrated circuit (IC) that is used in a variety of timer, delay, pulse gene...
- 3D Printed Arduino Halloween Décor When the full moon is shining and the wolves are howling, it's time for Halloween's spooky spectacle...
- All About RCWL-0516 Microwave Radar Motion Sensor Proximity sensing is a very common application in electronics.There are several ways to accomplish t...
- Transformers PCB BADGE It's been a while, the Autobots have appeared on the silver screen. Finally they are returning to th...
- LED Fader Using 555 Timer IC LED Fader Using 555 Timer ICWanted to generate a LED fading effect (fade-in and fade-out) for my upc...
- Arduino Based Concrete Clock With Touchless Night Lamp When you mix creativity with electronics, it becomes a masterpiece.Producing something original and ...
- DIY - PCB Christmas Forest Created a small "PCB Christmas Forest" which is going to light up my study table this Christmas.In t...
- PCB Christmas Forest A small Christmas Village For Someone You Love
- TM1637 Digit Display with Arduino IntroIn my hand is a 4-Digit 7-Segment display module.The heart of this module is an inexpensive Ser...
- IR Remote Tester and Decoder IntroWhat do you generally do when your remote controls starts playing up?Do you generally use a mul...
-
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
154 1 1 -
-