Fade in and fade out
Materials required-:
- Led
- Arduino
- 1k Resistor
- Jumpers
- Breadboard
This is a simple circuit in which you can control the brightness of led with the help of code . you can also use a resistor less than 1k or may be for more good results don't use a resistor . I Hope you all will enjoy this .If you want me to make a post on your idea or project just let me know in the comment section.
HAPPY LEARNING!
ARDUINO CODE
int led = 9; // the PWM pin the LED is attached toint brightness = 0; // how bright the LED isint fadeAmount = 5; // how many points to fade the LED byvoid setup() {// declare pin 9 to be an output:pinMode(led, OUTPUT);}void loop() {// set the brightness of pin 9:analogWrite(led, brightness);// change the brightness for next time through the loop:brightness = brightness + fadeAmount;// reverse the direction of the fading at the ends of the fade:if (brightness <= 0 || brightness >= 255) {fadeAmount = -fadeAmount;}// wait for 30 milliseconds to see the dimming effectdelay(30);}
For any queries contact me on -:tombriddle28@gmail.com
YouTube Channel-: Omnific{If this post helps you please do subscribe my
YouTube channel too ,It's only a click for you but it means a lot to me.}

Comments