Fade in and fade out

 Materials required-:

  1. Led
  2. Arduino
  3. 1k Resistor
  4. Jumpers
  5. 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 to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by


void 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 effect
  delay(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

Popular posts from this blog

Automatic Water Pumping System

Wireless Communication Between Two Arduino Board Using HC-05 Module

Interfacing "Bluetooth Module" with Arduino Uno