LED MANIPULATION - 2

Hello Friends, 
    I am Cyberautics  in previous session we make a fun program using Arduino and led lights.
Now we will make another fun program using Arduino and led.If due to some causes still you not read previous session then you can Click Here .

BASIC

  1. We make connection of LED lights with Arduino and make it.
  2. we connect LED separately but with common ground.
  3. we have to program the Arduino for LED sequence 

COMPONENTS

  1. Arduino
  2. LED Light
  3. Breadboard/PCB
  4. Jumper wires

CIRCUIT DIAGRAM



+ve terminals are connected with the digital pins and -ve terminals are connected with the ground.

CODE

//make a conection as per diagram...

#define red 3  // define red pin
#define green 4  // define green pin
#define blue 5 // define blue pin

void setup() {
//declaration of output of Red
 pinMode(red, OUTPUT);  
 //declaration of output of Green
 pinMode(green, OUTPUT);
//declaration of output of Blue
 pinMode(blue, OUTPUT);  
 Serial.begin(9600);
}

void loop() {
  digitalWrite(red, HIGH);   //red led high(ON)
  delay(1000);  // set delay 
  Serial.println("RED is on");
  digitalWrite(red, LOW);  // red led low(OFF)
  delay(1);   //set selay
  Serial.println("red is off");

  digitalWrite(green, HIGH);   //green led is on
  delay(1000);
  Serial.println("green is on");
  digitalWrite(green, LOW); // green led is off
  delay(1); //set delay for sleep
  Serial.println("green is off");
  
  digitalWrite(blue, HIGH);    //blue led on
  delay(1000);
  Serial.println("blue is on");
  digitalWrite(green, LOW);    //blue led off
  delay(1); //set delay for sleep
  Serial.println("blue is off");
}

EXPLANATION

  • First of all make a connection as per diagram .
  • Copy this code and paste it on the Arduino IDE and compile it .
  • After compilation upload it .
  • Red, Green and Blue are connected with the Arduino respectively 3,4 and 5.
  • When Red LED is on then remaining two LEDs are off same as for Green and Blue .


  • When the code is successfully compiled and upload to the Arduino the LED is follow this 3 sequence in some specific delay.
  1. when red LED  is on, green and blue LEDs are off .
  2. when green LED is on, red and blue LEDs are off.
  3. when blue LED is on,red and green LEDs are off.

EXERCISE

  • Make circuit diagram and Arduino code for following working:
  • Use 3 LED Light which is on sequentially and off  in reverse sequence.

So, My dear friends I hope this blog very useful for you , if you like this blog please share and if you have any doubt or any question you can contact me.
 

Comments

Post a Comment