Arduino fading effect of a led

Introduction

In this tutorial, we are going to make a simple Arduino fading effect of a led project, we’re going to make a led flash progressively so we’ll have a fade-in fade-out effect.​I so please follow the instructions and upload the code properly.

Arduino is a versatile microcontroller that can be used to control a variety of electronic components. One such component is an LED, which can be controlled to produce various effects, including a fading effect. In this project, we will use Arduino to create a fade-in and fade-out effect for an LED. This project is a great introduction to using analog outputs with Arduino, and it can be used in a variety of applications, including lighting systems, mood lighting, and more.

Hardware Required

We will need the following components to make the Arduino fading effect of a led Project you can buy these components online store.

Components#Buy From Amazon
Arduino UNO1Buy Now
LED 5mm1Buy Now
Resistors 220Ω1Buy Now
Jumper Wires3Buy Now
Breadboard1Buy Now

Circuit Diagram

Arduino-fading-effect-of-a-led-Circuit

Working Explanations

To create a fading effect of LED with Arduino, we will use the PWM (Pulse Width Modulation) technique. PWM is a method that changes the width of a pulse by modulating its amplitude. This technique helps us to control the voltage or current provided to the LED. The duty cycle of a PWM signal determines the brightness of the LED.

In this project, we will connect the LED to the digital pin 9 of Arduino, which supports PWM. We will vary the duty cycle of the PWM signal using the analogWrite() function to make the LED fade in and out.

The analogWrite() function takes two arguments: the pin number and the duty cycle value. The duty cycle value can range from 0 (LED is off) to 255 (LED is fully on). By varying the duty cycle value, we can control the brightness of the LED.

We will use a for loop to change the duty cycle of the PWM signal from 0 to 255 and then from 255 to 0. We will also add a delay between each step to make the fading effect more noticeable.

Installing Arduino IDE Software

First, you will require to Download the updated version of Arduino IDE Software and Install it on your PC or laptop. if you Learn How to install the Arduino step-by-step guide then click on how to install Arduino Button given Blow

Code

//For more Projects: www.arduinocircuit.com

int sheen = 0; // define the variable "gloss" with initial value 0
int increment = 5; // define the variable "increment" with value 5

void setup()
{
pinMode(9, OUTPUT); // define port 9 as the output port
}
void loop()
{
analogWrite(9, gloss); // send port 9 a voltage equal to (5/255) * shine
shine = shine + increase; // change the shine value
if (sheen == 0 || sheen == 255) // the symbol || is a boolean operator that
// represents the "or" while == is the symbol conventionally used to verify the
// equality condition. The normal = symbol is not used because the program lo
// would interpret as assigning a value e.g. gloss = 0 would be interpreted
// like "assign 0 to the gloss variable"
 {
 increment = increment *-1; // if the brightness has reached the extremes (0 or 255)
 // change sign on increment (multiply it by -1 and so if
 // was 5 makes it -5 and vice versa)
 }
delay(50); //wait 50 milliseconds before restarting the loop
}

Applications

  1. The use of this project is a decorative lighting system for events like parties, weddings, etc.
  2. It also uses in automobiles as an indicator light to grab attention.
  3. The use of this project in toys creates an interesting lighting effect.
  4. This project can also be used in street lighting systems to save energy.
  5. It can be used in emergency vehicles as a signal light.

Conclusion

This project demonstrates how easy it is to create a fading effect of LED using Arduino. The PWM technique is wide uses to control various devices, and this project is just a small example of its usage.

Leave a Comment


error: