How to Fade LED with Arduino | Fade LED | INNOVATIVE SCIENTIFIC INVENTIONS |


Hello Friends!Welcome back to 'INNOVATIVE SCIENTIFIC INVENTIONS'. Today I will show you. How to Fade LED with Arduino UNO.



Circuit Diagram: 


Code: 





           //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

// the setup routine runs once when you press reset:
void setup() {
  // declare pin 9 to be an output:
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
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);
}



 What do you need to create this project?

  1. Arduino UNO.
  2.  LED 



How to Upload Code in Arduino:
  1. Open Arduino IDE.
  2. Paste the code in Arduino IDE.
  3. Compile the Code.
  4. Upload the Code in Board.


How to Select Board:
  1. Open Arduino IDE
  2. Click on 'Tools' Option
  3. Click on 'Board'
  4. Select your Board


How to Select Port:
  1. Open Arduino IDE
  2. Click on 'Tools' Option
  3. Click on 'Port'
  4. Select your Port

How to Save Sketch in Computer:
  1. Open Arduino IDE
  2. Click on 'File' Option
  3. Click on 'Save' Option
  4. Select your Folder

How to 'Save as' Sketch:
  1. Open Arduino IDE
  2. Click on 'File' Option
  3. Click on 'Save as' Option
  4. Select your Folder

IF YOU WANT TO DONATE FOR "INNOVATIVE SCIENTIFIC INVENTIONS" SO PLEASE CONTACT ME.


WHATSAPP: +923110084691

EASY PAISA: +923327810553







                  Click Here to Download Arduino IDE 
Arduino IDE Download Link:

Post a Comment

0 Comments