Blinking LED

Blinking LED is the first Arduino Application, that one can start with while getting started with the Arduino Practical Application. This is the smallest project to start with and will give you a hands-on experience of using the Arduino Board.

See LIVE demo of the Project- Click here to see

Hardware Components Required :

  • Arduino UNO Board
  • One LED
  • Bread Board
  • One 220 ohm resistor
  • jumper wires.

Software Required

  • Windows 32 OS or higher.
  • Arduino Software.

A Brief Description of LED

arduino-led-details

In the diagram, you can see that the Positive terminal is a little larger length then than the negative terminal. This is the way to figure it out, the terminals of the LEDs. (Any LED brought from the market)

Steps to prepare the project

Step 1: Preparing the Circuit Connections

Connect all the components as shown below:

  • The Negative Terminal of the LED is connected to the GND of the Arduino Board.
  • The Positive Terminal of the LED is connected to the PIN 8 of the Arduino Board via a 220-ohm Resistor.

arduino-blink-led

Step 2: Writing the Blinking LED Sketch

To write the sketch(Program) for the Blinking LED, just open the Arduino Software And Open a new empty Sketch. Edit the following code into the Arduino IDE.

int ledPin = 8; //definition digital 8 pins as pin to control the LED
void setup() {
    pinMode(ledPin, OUTPUT); //Set the digital 8 port mode, OUTPUT: Output mode
}
void loop() {
    digitalWrite(ledPin, HIGH); //HIGH is set to about 5V PIN8
    delay(1000); //Set the delay time, 1000 = 1S
    digitalWrite(ledPin, LOW); //LOW is set to about 5V PIN8
    delay(1000); //Set the delay time, 1000 = 1S
}

Program Analysis :

  • Initialize a variable called ledpin and assign it with PIN 8.
  • Set the mode of the PIN 8 into OUTPUT.
  • Using the digitalWrite() function set the ledpin to HIGH
  • Create a delay of 1000 milliseconds to sustain the HIGH voltage(5 V).
  • Using the digitalWrite() function to set the ledpin to LOW.
  • Again create a delay of 1000 milliseconds to sustain the LOW voltage(0 V)

Edit the Code in the IDE

Once you have the code inside the editor. You must see the screen as below.

arduino-blinking-led-sketch

Verify the Sketch

After writing the code into the Arduino IDE, it should be verified. It is necessary so that if there is some syntax or logical error in the code, it will be displayed and you get a chance to correct them before uploading.

arduino-sketch-verify

It should be noted that in the verification phase, the compilation is done at the same time.

arduino-sktech-compile

Once, no error is displayed, you are ready to upload the code into the board.

An error-free compilation does not mean that your program is meaningful. Your program may not contain adequate code or logic that is required to perform the desired action.

Upload the code

Once, verified, you can simply upload the sketch into the Arduino Board.

arduino-led-sketch-upload

FAQ

Why have we used the 220-ohm Resistor?

The Arduino Digital PINS (PIN 8 in our case) will give an output of 5 volts. Now, there can be an LED whose operating voltage is 2 Volts (any lower than 5 volts), in that case, the LED may burn out.

So, we have used the resistor to supply less voltage to the LED.

Can the project be done without using the Bread Board?

Yes. But, it is always a good practice to use the Bread Board, so that you get used to with complicated projects.

Can we use a different color LED?

Of course Yes!

Why Digital Pins are used?

Since we require either HIGH or LOW voltage for Blinking LED Project.

Which Arduino Board is recommended?

Any Arduino Board you can use.

Can I use any GND Pin available on the Arduino Board?

Yes!

Can I connect a DC motor in the place of the LED?

You can, but you should not. The DC motor has very low resistance and it will try to draw more current from the Arduino Board and may burn the Arduino itself.

To use any component which requires more current, different hardware device drivers are used.

Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions