LED blinking means creating a project so that an LED will be on and off after a certain period of time. Thus a rhythm has to be created.

Circuit

All you need to do to be a Proteus peak device is –

  1. Arduino.
  2. LED.

Now we connect the positive edge of the LED with pin 10 of Arduino and connect it with the negative edge like a circuit with ground connection like this figure. 

Code

At the beginning we write the code, then it will be understood.

int led = 10;

void setup ()

{

  pinMode (led, OUTPUT);

}

void loop ()

{

  digitalWrite (led, HIGH);

}

We will first take a variable. Here, since we have attached the LED to pin number 10 of the Arduino, we take this pin as a variable called ‘led’. Whose value is 10. That means writing pin number 10 somewhere or writing ‘led’ is the same thing. And these variables can be of different types. Here we will take the value of the variable as 10 which is an integer type. So I have denoted this variable with int. Then we take a function called void setup (). The function of this function is to specify here – which variable or which pin will work. That is, the pin will work as input or output. Which must be written in parentheses of pinMode. Since our pin number 10 will act as the output depending on which LED is on or off, I wrote. pinMode (led, OUTPUT); . As I said before, the word led means pin number 10. Because we named it led. And in the continuous rule of programming, everyone has to give a semicolon at the end of the line.

Again we call a new function. That is void loop (). The function of this function is to specify the function here. That is, what we have mentioned in the void setup () function, in this function they have to explain the work. Another function of this function is to follow the instructions we give in it, after the work is finished, all stops from which the work will be repeated. That is, once you follow the instructions, you will not stop, you will start that instruction again from the beginning. Until then, the previous instructions will continue. So we wrote in this function, digitalWrite (led, HIGH); . That means the positive edge of pin number 10 or led will be HIGH. And HIGH means – ON or binary number 1.

Once the code is compiled, we will get a .hex file on the C drive below. Someone must go to the Preferences from the File menu and turn on the Compile and Upload menus. Now copy the link of the hex file, double click on the Arduino of Proteus, paste it in the Program File and click OK. Now if we run the project, we will see that the LED is on. Not extinguished. Why not go out? The answer is simple. Because we have digitalWrite (led, HIGH) in void loop () function; Wrote. Which means, the LED will be on or the pin number 10 will be HIGH. LOW was not mentioned. So it will burn, not extinguish. But our intention was to turn the LED on and off. Let’s do that.

This time we give the input program again as before,

int led = 10;

 

void setup ()

{

  pinMode (led, OUTPUT);

}

void loop ()

{

  digitalWrite (led, HIGH);

  delay (1000);

  digitalWrite (led, LOW);

  delay (1000);

}

We will first take a variable. Here, since we have attached the LED to pin number 10 of the Arduino, we take this pin as a variable called ‘led’. Whose value is 10. That means writing pin number 10 somewhere or writing ‘led’ is the same thing. And these variables can be of different types. Here we will take the value of the variable as 10 which is an integer type. So I have denoted this variable with int. Then we take a function called void setup (). The function of this function is to specify here – which variable or which pin will work. That is, the pin will work as input or output. Which must be written in parentheses of pinMode. Since our pin number 10 will act as the output depending on which LED is on or off, I wrote. pinMode (led, OUTPUT); . As I said before, the word led means pin number 10. Because we named it led. And in the continuous rule of programming, everyone has to give a semicolon at the end of the line. 

Again we call a new function. That is void loop (). The function of this function is to specify the function here. That is, what we have mentioned in the void setup () function, in this function they have to explain the work. Another function of this function is to follow the instructions we give in it, after the work is finished, all stops from which the work will be repeated. That is, once you follow the instructions, you will not stop, you will start that instruction again from the beginning. Until then, the previous instructions will continue. So we wrote in this function, digitalWrite (led, HIGH); . That means the positive edge of pin number 10 or led will be HIGH. And HIGH means – ON or binary number 1.

Once the code is compiled, we will get a .hex file on the C drive below. Someone must go to the Preferences from the File menu and turn on the Compile and Upload menus. Now copy the link of the hex file, double click on the Arduino of Proteus, paste it in the Program File and click OK. Now if we run the project, we will see that the LED is on. Not extinguished. Why not go out? The answer is simple. Because we have digitalWrite (led, HIGH) in void loop () function; Wrote. Which means, the LED will be on or the pin number 10 will be HIGH. LOW was not mentioned. So it will burn, not extinguish. But our intention was to turn the LED on and off. Let’s do that.

This time we give the input program again as before,

int led = 10;

 

void setup ()

{

  pinMode (led, OUTPUT);

}

void loop ()

{

  digitalWrite (led, HIGH);

  delay (1000);

  digitalWrite (led, LOW);

  delay (1000);

}

Here we call a new function called delay (). Its function is to run or delay the instruction exactly as it is written inside this function for as many milliseconds as it is written. Then according to the code-

  digitalWrite (led, HIGH); – The LED will be on.

  delay (1000); – This is how 1000 milliseconds will run.

  digitalWrite (led, LOW); – The LED will be off.

  delay (1000); – This is how 1000 milliseconds will run.

After doing this, the program will start working from the top again according to the function of void loop () function.

The LED will continue to be on for 1000 milliseconds or 1 second in a row.

You can increase or decrease the time of this deal if you want. But keep in mind, whatever we write inside, the delay time will be as many milliseconds.

At the next part I will discuss advance thinking on this LED blinking project. 


Written

Jeion Ahmed

Electrical and Electronic Engineering (EEE)

Chittagong University of Engineering and Technology (CUET)

Leave a Reply