Hello Friends,
I am Cyberautics , and Previous session we learn about the working with LDR sesnor and LED and in this session we learn about light fading system with time and light will increment and decrement.Specially you still not read the led interface click and read.
BASICS
- We already learn the interfacing the LED and now we learn how to manipulate LED
- We give voltage to the LED as analog because digital has only 0 and 1 which can only work for LED on and off.
- We give analog and LED slowly glow up and slowly off.
COMPONENTS
- Arduino
- LED Light
- Breadboard/PCB
- Jumper wires
SCHEMATIC DIAGRAM
We have to connect circuit as per given diagram and we can use the Resistor of 220 ohm but it is optional . Your circuit still work without resistor.
CODE
int led =11; //define led pin
int i; // declare variable for loop
void setup() {
pinMode(led, OUTPUT); //make led output
Serial.begin(9600);
}
void loop()
{
//we use for loop for increase light in sequence
for(i=0;i<=255;i++) // for increase light
{
// output is analog because digital has only on and off factor
analogWrite(led, i);
delay(50); //as you want you can set
Serial.println(i); // we take i as our output
}
{
//for loop for decrease light
for(i=255; i>=0;i--) // for decrease light
{
analogWrite(led, i); //variable i as an output which decreasing its brightness
delay(50); //as you want you can set
Serial.println(i); //take a value of i as an output
}
Serial.println(i); //take a value of i as an output
}
}
}
EXPLANATION
- This code is manipulate the LED light to perform a specific task.
- we make LED light as a analog output.
- It's value increasing from 0 to 255 , and after that the value is start decreasing from 255 to 0.
- when the value is 0 then LED has lowest luminous and when the value is 255 then it has it's highest luminous
- We can see in the image by yellow highlight it's value is increase till 255 and after reach at highest value it will start to decrease till 0.
- This all task perform using for loop we mention in the earlier blog , if you not read that then click here .
so, My dear friends I hope this video is useful for you if you have any doubts or confusion you can contact me.
Cool 🙌
ReplyDeleteVery nice & useful.....keep it up
ReplyDeleteVery good information 👍
ReplyDelete