LED BLINKING USING ARDUINO UNO

Led Blinking using Arduino UNO – To get a blinking led we need the same connection as we made to glow an LED.

Blinking means turning ON an LED on for one second, then OFF for one second, repeatedly. In this section we will see how to program Arduino to blink an LED.

Required hardware or components for Lighting up LED using Arduino

S.N.ComponentQuantity
1.Arduino Uno1
2.Breadboard1
3.LED1
4.Resistor 220 or 280 ohm1

CIRCUIT DIAGRAM : LED BLINKING USING ARDUINO UNO

Light up led using arduino circuit diagram
Light up led using Arduino – circuit diagram

CONNECTION TABLE

S.N.ArduinoLED
1.13Anode (+)
2.GNDCathode (-)

ARDUINO CODE : LED BLINKING USING ARDUINO UNO

void setup() {
  pinMode(13, OUTPUT);
}
void loop() {
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}

CODE EXPLANATION

Step-1:

In the setup() function we decide the mode of digital pins either as INPUT or OUTPUT. Let’s concentrates on output for now.
Function pinMode() ” is used to define the pin working mode as an input/output.
In this function we have to pass two argument –

  1. First one is pin number and
  2. Second is its mode, pinMode(pinNumber, mode).

In this we set pin number 13 as output: pinmode(13, OUTPUT).

void setup() {
  pinMode(13, OUTPUT);
}

Step-2:

In loop function we are using two inbuilt functions that are digitalWrite() and delay().

Function digitalWrite() is used to instruct the controller/Arduino to set the state of a particular digital pin as LOW or HIGH. In the digitalWrite() function we also pass two arguments that are one is pin number and second is state digitalWrite(pinNumber, state). We are setting pin number 13 as high.

And the second function is delay() which is used to provide delay to the upper instruction, so that the next instruction will wait till the delay time gets completed. In delay we pass one parameter that is time to be delayed in milliseconds. Here we want to delay the pin number high state for 1000 milliseconds or 1 second. In simple words –

  1. We set pin number 13 state to high
  2. Give delay of 1 second
  3. Then we again change pin number 13 state to low
  4. Then delay by 1 second
  5. And the loop will start repeating instructions again and again.
void loop() {
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}

And the loop gets executed continuously and follows the same pattern.


NEXT READ
BLINK LED’S IN STACK FORM USING ARDUINO


 

5 1 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x