You Me And Programming!

My Instagram (@saai9111)

My YouTube Channel

Code To Make Fading LED Using Arduino.....

-----------------------------------------------------------------------------------------

You Will Need:

1. Arduino Board (I Am Using Arduino UNO)
2. A Data Cable
3. LED Lights
4. Male To Female Jumper Wires

------------------------------------------------------------------------------------------

Here's The Code.....

------------------------------------------------------------------------------------------

int ledPin = 11;    // LED connected to digital pin 11

void setup()  {
  // nothing happens in setup
}

void loop()  {
  // fade in from min to max in increments of 5 points:
  for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);       
    // wait for 30 milliseconds to see the dimming effect   
    delay(100);                           
  }

  // fade out from max to min in increments of 5 points:
  for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
    // sets the value (range from 0 to 255):
    analogWrite(ledPin, fadeValue);       
    // wait for 30 milliseconds to see the dimming effect   
    delay(100);                           
  }

}

------------------------------------------------------------------------------------------

Here's Another Code..........

------------------------------------------------------------------------------------------


#define LED 11

void setup() {
  pinMode(11, OUTPUT);

}

void loop() {
  int i;
  for(i=0;i<255;i++){
    analogWrite(11, i);
    delay(100);
  }
  for(i--;i>255;i=0){
    analogWrite(i, 11);
    delay(100);
  }


}

---------------------------------------------------------------------------------------------

Code For Making Blinking LED.......

---------------------------------------------------------------------------------------------

You Will Need.......
*Material Same As For Fading LED And Blinking LED*

--------------------------------------------------------------------------------------------

Here's The Code.........

--------------------------------------------------------------------------------------------


#define LED 11

void setup(){
  pinMode(11, OUTPUT);
 
}
void loop(){
  digitalWrite(11, HIGH);
  delay(70);
  digitalWrite(11, LOW);
  delay(2000);
}

--------------------------------------------------------------------------------------------

Follow Me On Instagram And Subscribe Me On YouTube


Comments

Popular Posts