Complete Guide How to Create a Blinking LED Wave 

Circuit layout

In this project, we’ll Create a Blinking LED Wave step by step complete process.

≡ Hardware Requirement :

  1. Five LEDs
  2. Five 560 Ω resistors
  3. One breadboard
  4. Various connecting wires
  5. Arduino and USB cable

≡ Create a Blinking LED Wave  Code:

// Project 1 - Creating a Blinking LED Wave
1 void setup()
    pinMode(2, OUTPUT);    // LED 1 control pin is set up as an output
    pinMode(3, OUTPUT);    // same for LED 2 to LED 5
    pinMode(4, OUTPUT);
    pinMode(5, OUTPUT);
    pinMode(6, OUTPUT);

2 void loop()
    digitalWrite(2, HIGH);  // Turn LED 1 on
    delay(500);             // wait half a second
    digitalWrite(2, LOW);   // Turn LED 1 off
    digitalWrite(3, HIGH);  // and repeat for LED 2 to 5
    digitalWrite(3, LOW);
    digitalWrite(4, HIGH);
    digitalWrite(4, LOW);
    digitalWrite(5, HIGH);
    digitalWrite(5, LOW);
    digitalWrite(6, HIGH);
    digitalWrite(6, LOW);
    digitalWrite(5, HIGH);
    digitalWrite(5, LOW);
    digitalWrite(4, HIGH);
    digitalWrite(4, LOW);
    digitalWrite(3, HIGH);
    digitalWrite(3, LOW);
    // the loop() will now loop around and start from the top again

≡ Code Analysis Create a Blinking LED Wave 

In void setup() at 1, the digital I/O pins are set to outputs, because we want them to send current to the LEDs on demand. We specify when to turn on each LED using the digitalWrite() function in the void loop() 2 section of the sketch.

≡ Create a Blinking LED Wave  Schematic

Now let’s create the circuit. A circuit layout can be defined in several ways.  we’ll apply physical layout diagrams similar to the one shown in Figure 1.

Circuit layout
Figure 1. Circuit layout

By linking the wiring diagram to the functions in the sketch, you can work to make sense of the circuit. For example, when we apply, a high voltage of 5 V flows from digital pin 2, through the current-limiting resistor, through the LED via the anode and then the cathode, and finally back to the Arduino’s GND socket to finish the circuit. Then, when we use digitalWrite(2, LOW), the current stops and the LED turns off.

≡ Running the Code

Now join your Arduino and upload the sketch. After a second or two, the LEDs should blink from left to right and then back again. Success is a fine thing—embrace it!

If nothing appears, however, then quickly remove the USB cable from the Arduino and check that you typed the sketch perfectly.  you see an error, fix it and upload your sketch again. If your sketch matches correctly and the LEDs still don’t blink, review your wiring on the breadboard.

You now know how to create an LED blink with your Arduino, but this sketch is somewhat inefficient. For example, if you needed to modify this sketch to make the LEDs cycle more quickly, you would need to alter each delay(500).

≡ Using Variables

we apply variables to store data. For example,  we worked the function delay(500) to hold the LEDs turned on.

The problem with the sketch as written is that it’s not very flexible. If we need to make a change to the delay time, then we have to change any entry manually. To address this problem, we’ll build a variable to represent the value for the delay() function.

Enter the following line in the  sketch above the void setup() function and just after the initial remark:

int d = 250;

This assigns the number 250 to a variable called d.

Next, change each 500 in the sketch to a d. Now when the sketch runs, the Arduino will use the value in d for the delay() functions. When you upload the sketch after earning these changes, the LEDs will turn on and off at a much faster rate, as the delay value is much smaller at the 250 value.

int indicates that the variable contains an integer—a whole number within−32,768 and 32,767. Simply put, any integer value has no fraction or decimal places. Now, to alter the delay, simply change the variable information at the start of the sketch. For example, entering 100 for the delay would speed things up even more:

int d = 100;

Experiment with the sketch, possibly altering the delays and the sequence of HIGH and LOW.

≡  Hardware Analysis Create a Blinking LED Wave 

Light-Emitting Diode(LED)

The LED is a very popular, infinitely helpful component that converts electrical current into light. LEDs come in various shapes, sizes, and colors. Figure 2 shows a common LED.

Red LED, 5 mm in diameter
Red LED, 5 mm in diameter

Joining LEDs in a circuit takes some care because they are polarized. this means that current can enter and leave the LED in one direction only. The current enters via the anode (positive) side and leaves via the cathode (negative) side, as shown in Figure 3.

Any effort to make too much current flow through an LED in the opposite way will break the component. Thankfully, LEDs are created so that you can tell which end is which. The leg on the anode side is longer, and the rim at the base of the LED is flat on the cathode side, as shown in Figure 4.

Figure 3-7. Current flow through an LED
Figure 3. Current flow through an LED
Figure 3-8. LED design indicates the anode (longer leg) and cathode (flat rim) sides.
Figure 4. The LED design indicates the anode (longer leg) and cathode (flat rim) sides.
If adding LEDs to a project, you require to study the operating voltage and current. For example, common red LEDs need around 1.7 V and 5 to 20 mA of current. This gives a slight problem for us because the Arduino outputs a set 5 V and a much higher current.
 we can utilize a current-limiting resistor to reduce the current flow into an LED. But which value resistor do we work? That’s where Ohm’s Law comes in. To calculate the wanted current-limiting resistor for an LED, apply this formula:
R = (Vs − Vf) ÷ I
where Vs is the supply voltage (Arduino outputs 5 V); Vf is the LED forward voltage drop (say, 1.7 V), and I is the current needed for the LED (10 mA). (The value of I must be in amps, so 10 mA converts to 0.01 A.)
Now let’s work this for our LEDs—with a value of 5 V for Vs, 1.7 V for Vf, and 0.01 A for I. Substituting these values into the formula gives a value for R of 330 Ω. But, the LEDs will happily light up when fed current less than 10 mA.
It’s good to work to apply lower currents when possible to protect sensitive electronics, so we’ll use 560 Ω, 1/4-watt resistors with our LEDs, which provide around 6 mA of current to flow.


Ohm’s Law states that the relationship between current, resistance, and voltage is as follows:

voltage (V) = current (I) × resistance (R)

If you know two of the quantities, then you can calculate the third. A popular way to remember Ohm’s Law is with a triangle, as shown in Figure 5.

 The Ohm’s Law triangle
Figure 5. Ohm’s Law triangle

Ohm’s Law triangle diagram is a useful tool for calculating voltage, current, or resistance when two of the three values are known. For example, if you require to calculate resistance, put your finger over R, which leaves you with voltage divided by current to calculate voltage, cover V, which gives you with current times resistance.


Different components, such as the Arduino’s LED, want only a small amount of current to work —usually around 10 mA. When the LED receives excess current, it converts the excess to heat—too much of which can kill an LED.

To decrease the flow of current to components such as LEDs, we can add a resistor between the voltage source and the component. Current flows easily along the regular copper wire, but when it encounters a resistor, its movement is slowed. Some current is transformed into a small amount of heat energy, which is equal to the value of the resistor. Figure 6 shows an example of commonly utilized resistors.



The level of resistance can be either set or variable. Resistance is included in ohms (Ω) and can range from zero to thousands of ohms (kiloohms, or kΩ) to millions of ohms (megohms, or MΩ).

Reading Resistance Values:

Resistors are very short, so their resistance value normally cannot be printed on the components themselves. Although you can test resistance with a multimeter, you can also read resistance direct from a physical resistor, even without numbers.

One common method to show the component’s resistance is with a series of color-coded bands, read from left to right, as follows:

  1. First band. Represents the first digit of the resistance
  2. Second band. Represents the second digit of the resistance
  3. Third band. Represents the multiplier (for four-band resistors) or the third digit (for five-band resistors)
  4. Fourth band. Represents the multiplier for five-band resistors Fifth band. Shows the tolerance (accuracy)

Table 1 lists the colors of resistors and their equal values. The fifth band represents a resistor’s tolerance. This is a model of the accuracy of the resistor. Because it is difficult to manufacture resistors with exact values, you select a margin of error as a percentage when buying a resistor.

A brown band registers 1 percent, gold registers 5 percent, and silver indicates 10 percent tolerance. Figure 7 shows a resistor diagram. The yellow, violet, and orange resistance bands are read as 4, 7, and 3, respectively, as listed in Table 1. These values translate to 47,000 Ω, more commonly read as 47 kΩ.

Example resistor diagram
Figure 7 Example resistor diagram
Table 1. Values of Bands Printed on a Resistor, in Ohms

Solderless Breadboard

Our ever-changing circuits will require a base—something to hold them together and build upon. An excellent tool for this purpose is a solderless breadboard. The breadboard is a plastic base with rows of electrically joined sockets (just don’t cut bread on them). They come in many sizes, shapes, and colors, as shown in Figure 8.

 Breadboards in various shapes and sizes
Figure 8 Breadboards in various shapes and sizes

The key to utilizing a breadboard is knowing how the sockets are connected—whether in short columns or in long rows along the edge or in the center. The connections change by the board. For example, in the breadboard shown at the top of Figure 9, columns of five holes are joined vertically but isolated horizontally.

If you place two wires in one vertical row, then they will be electrically attached. By the same symbol, the long rows in the core between the horizontal lines are attached horizontally. Because you’ll often require to connect a circuit to the supply voltage and ground, these long horizontal lines of holes are ideal for the supply voltage and ground.

When you’re making more complex circuits, a breadboard will get crowded and you won’t always be able to place components exactly where you want. It’s easy to solve this problem by using short connecting wires, however. Retailers that sell breadboards normally also sell small boxes of wires of various lengths, such as the assortment shown in Figure 10.

Breadboard internal connections
Figure 9. Breadboard internal connections
 Assorted breadboard wires
Figure 10. Assorted breadboard wires

All Arduino tutorial available Click here


 227 total views,  1 views today