Project 2 - Blinking LEDs arranged to form the number 1

Hello friends! Welcome to another post!
In this post we will make our next project which is - Blinking LEDs arranged to form the number 1.
Before we begin I hope you have installed Arduino IDE. If not you can read this -  How to Download Arduino IDE.

Here are the terms we will use in our programming
int led = number;
void setup();
void loop();
pinMode(variable, text);
digitalWrite(variable, text);
delay(number);

I hope you all know about these terms. If  not you can read this - The terms used in Arduino IDE

Let's begin!

The components you need - 
Arduino UNO Board (x1) {If you don't have Arduino UNO board then you can use any other board}
Wires (The number of wires depends on the number of LEDs you use)
Breadboard(x1) - Can be long or short. I would recommend the long one for this project. But if you have short then take 3 LEDs
Arduino Power Cable (x1)
LEDs (The number of LEDs should be between 3 to 8)

The process-
1. Attach 1 LED on the board. Remember attach the anode and the cathode next to each other.
 2. Now add a resistor on cathode row.
It should look like this -
 
Image made using www.tinkercad.com
Now repeat this step till all the LEDs you took are over.
It should look like this  (I have shown 8 LEDs but you may have less so don't worry)- 
Image using www.tinkercad.com
Connections:
3. Take a wire and place it in the Arduino UNO board GND ( '-' signal)
4. Connect the other end like this - 

Image created using www.tinkercad.com
5. After connecting the wire, take another wire and connect it to the resistor column (column of boxes) and connect the other end of the wire right beside the wire we connected in step 4.
Repeat this for all the resistors, like this (don't worry if you don't have the same color wires, the color dosen't matter) - 
Image created using www.tinkercad.com
6. Now, take another wire and connect it to the anode row of one LED and connect the other end to digital pin 13. In the same way, we will connect another wire and connect it to digital pin 12.
Here are the anode connections of the 8 LEDs (in text)-
LED 1 - digital pin 13
LED 2 - digital pin 12
LED 3 - digital pin 11
LED 4 -  digital pin 10
LED 5 - digital pin 9
LED 6 -  digital pin 8
LED 7 -  digital pin 7
LED 8 - digital pin 6

It should look like this  (you can't see the wire connections clearly, so just look at the above text for the connections)- 
Image created using www.tinkercad.com
Let's code!
Type this into Arduino IDE - 
/*
 Remember: the number you put after 'int led1', 'int led2' and so on may be different
 so put the correct digital pin for each LED is whichever variable you have created for
 LED 1, 2, 3...
 */
//This code is to make 5 LEDs which are arranged to make the number 1 on and off alternatively
int led1 = 13; //LED 1 is connected to digital pin 13
int led2 = 12; //LED 2 is connected to digital pin 12
int led3 = 8; //LED 3 is connected to digital pin 11
int led4 = 10; //LED 4 is connected to digital pin 10
int led5 = 9; //LED 5 is connected to digital pin 9

void setup()
{
  //This code will run only once
  /*
   The following lines of code will define if LED 1, LED 2, LED 3, LED 4 and LED 5 are OUTPUT or INPUT.
   I will keep all the LEDs as output.
   */
   pinMode(led1, OUTPUT);
   pinMode(led2, OUTPUT);
   pinMode(led3, OUTPUT);
   pinMode(led4, OUTPUT);
   pinMode(led5, OUTPUT);
}
void loop()
{
  //This code will run repatedly
  /*  
   Since the code is meant to make 5 leds on and off alternatively we will fist make LED 2, and LED 4 on while all the others will be off
   */
   digitalWrite(led1, LOW);
   digitalWrite(led2, HIGH);
   digitalWrite(led3, LOW);
   digitalWrite(led4, HIGH);
   digitalWrite(led5, LOW);
   delay(1000); //Gap of 1 second before other LEDs are on
   /*
    We will know make LED 2 and 4 off while all the others will be on.
    */
    digitalWrite(led1, HIGH);
    digitalWrite(led2, LOW);
    digitalWrite(led3, HIGH);
    digitalWrite(led4, LOW);
    digitalWrite(led5, HIGH);
    delay(1000); //Gap of 1 second before the whole code in the void loop repeats.
}

Connect your Arduino UNO board to your computer and then verify and upload your code (if you don't know how to verify and upload the code the read this - Verify and Upload your code)

Here is how your project will be:





The Project




Thank You!








Comments

Popular posts from this blog

Light

Welcome to my blog!