Components Required:

2 x Jumper Wires
m2m
1x Breadboard
breadboard
1 x 220 ohm Resistor
220-ohm-resistor
1 x LED
led

Procedure:

Step 1: Connect the Arduino Uno with PC/Laptop using USB cable.

Step 2: Make the connections of Arduino with the LED according with the schematics.

Step 3: Open the Arduino IDE (Arduino IDE Installation) and write down the below mentioned code.

Step 4: Press Ctrl+R  on keyboard to verify and upload the code in the Arduino.

Code:

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.
*/


// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);              // wait for a second
}

Code Explanation:

 pinMode(13, OUTPUT);

In the above line of code pin 13 on the Arduino board is being initialized in the OUTPUT mode. Remember the value 13 can be changed depending upon which pin the led is connected to.

 digitalWrite(13, HIGH);

This line of code lights up the LED. This supplies 5 volts to the LED anode. That creates a voltage difference across the pins of the LED, and lights it up.

 digitalWrite(13, LOW);    

This statement takes the pin 13 back to 0 volts, and turns the LED off.

 delay(1000);

the delay() commands halts the board for 1000 miliseconds i.e. 1 second and it makes the blinking effect happen.

LED (Light Emitting Diode):

led

Schematics:

  • Place LED in the Breadboard.
  • Connect the long leg of the LED (the positive leg, called the anode) to the one end of the resistor.
  • Connect the short leg of the LED (the negative leg, called the cathode) to the GND with the help of jumper wire.
  • Use jumper wire to connect the other end of resistor to PIN 13