IoT Hacks for IoT geeks. http://iot-hacks.com

Blink an LED with Arduino UNO

12:08 AM Posted by Gopal Lal No comments
Blinking of an LED is continuously changing the state of led that's mean to On and Off. Since the Arduino has its pins high at 5V and low at OV so it easily can drive an LED. Lets start with the circuit. Here is the systematic of the circuit made on  Proteus ISIS.

I have connected the LED to pin 13 and a resistor of about 220 Ohm is connected in series with led and the connected that to ground.
The resistor is used to limit the current through led. Now let us move to the Arduino program sketch. Here is it.


// Led Blink Program 
// We connect an LED on  Pin 13. 
// Most arduino has an LED connected on Pin 13.
// Name pin 13 as led.
int led = 13;
void setup() {                
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);     
}
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on 
  delay(500);               // wait for 500 mili second
  digitalWrite(led, LOW);    // turn the LED off 
  delay(500);               // wait for 500 mili second

}



Here we have named Pin 13 as 'led'. First in setup() block we will initialize the pin 13 ('led') as output. In loop() we will on and off the led so first write digital HIGH on 'led' and the wait for 500 ms. After that off the led so write digital LOW and give a delay of 500 ms. And thus loop will run continuously and the led will blink.
For any type of help just comment below. It would be my pleasure to help you. 

0 comments:

Post a Comment