Ajantha College and School Students Science Projects materials The Great in project

"In the name of Allah, most
Gracious, most Compassionate"

Phone

044 4213 1795

Mobile

+91 91764 16648
 

Blink LED with Arduino – say Hello World

Blink LED with Arduino – say Hello World

When we learn a new programming language in computer science (say C, PHP or Java), we begin the learning curve with the classic “Hello World” program. We learn some essential keywords used in the programming language, then we learn the structure of the language and finally we begin to play with the language by making it display the two words “hello world” in our computer screen. So that’s how we begin to learn a programming language used to build computer applications. Our world of embedded systems is a little different. We create software to control hardware. In our world, we begin our learning curve by saying “hello world” using an LED. Our way of “hello world” is blinking an LED using the micro controller under study.

In this article, we are going to blink an LED using our arduino board. I will be using an Arduino Uno board to demonstrate the whole process. Before going deep, if you are very new to arduino, I suggest you read the following articles.

What is Arduino – for Beginners is a great article to begin with. It explains arduino to a naive person. You will learn the basics needed from this article.

2. The Arduino Hardware and Software – explains the different arduino boards, different micro controllers used in them, tells in detail about the software IDE and a little bit about programming language as well.

The History and Story behind Arduino If you are interested in knowing about the history behind development of Arduino board.

Now lets begin playing with our LED adventure. You need an arduino board, an LED, a resistor and a breadboard. Once you have these components in hand, you need to install the Arduino IDE (Integrated Development Environment) on your computer. In addition, you need to setup and configure your Arduino board in your computer (by installing the device driver).

Blink LED with Arduino

Open the arduino IDE and write the following program to blink an LED. I have written the classic LED blinking example provided in the book Getting Started with Arduino. You may see the screenshot below. After writing the program you may save it with a file name of your choice (find File–>Save on menu bar of IDE)

 
stereo amplifier circuit BA5417
 

Now we have to load the program from the PC to our arduino board. To do this perfectly, you have to ensure the following steps.

STEP 1 – Selecting the board

You have to select the arduino board type in your IDE. I am using an Arduino Uno board. To choose the board, find Tools on menu bar. Choose the option “Board” – and select your correct arduino board. I have chosen arduino uno. See the screenshot.

 
stereo amplifier circuit BA5417
 

STEP 2 – Select the right port

The port number is assigned while installing the hardware driver of board. You may refer the tutorial on Installing Arduino on Windows to know how to find the port number of board. You can find the port number by accessing device manager on Windows. See the section Port (COM & LPT) and look for an open port named “Arduino Uno (COMxx)“. If you are using a different board, you will find a name accordingly. What matters is the xx in COMxx part. In my case, its COM5. So my port number is 5. To select the right port, go to Tools–> Serial Port and select the port number. Refer screenshot below.

 
stereo amplifier circuit BA5417
 

Now everything is ready. Your arduino board is ready to communicate with your PC and vice versa. Instructions will be send to arduino board from your PC. Now lets see how to do that. There are two steps involved in loading the program from your PC to arduino board via the arduino IDE. First step is compiling and second step is called burning. Let’s see in detail.

STEP 1:- Compiling - This is the process of converting the code you have just written in arduino IDE to another form which is only understood by the micro controller in your arduino board. In our example, we use arduino uno board. It is made using Avr micro controller (Atmega328). In the arduino IDE, compiling is called as “verify“. So hit the verify button in your IDE (see the button with tick mark just below menu bar). Refer the screenshot given below as well. When you hit the verify button, the program you have written in arduino IDE will be compiled for any errors and then converted to another form that Avr Atmega328 understands. You may refer our article on the Arduino Software and Hardware to know in detail about the language used in arduino.

 
stereo amplifier circuit BA5417
 

STEP 2:- Burning – Embedded designers use the word “burning” to refer to uploading a program to any micro controller. So in this step, we are going to upload the verified program in arduino IDE to the arduino board. To do this, press the “upload” button (see the button with right arrow mark). A click on the “upload” button will begin the process of burning the compiled program to Avr micro controller on your arduino board. Depending on the size of your program, this will take a little time. If you look on your arduino board, you can see the 2 LED’s near Tx and Rx blinking. This is an indication of successful communication between your PC and arduino board. If the program has been uploaded successfully, you will see a message like “Done Uploading“. If the uploading process was not successful, you will see an error message accordingly. Refer the screenshot given below.

 
stereo amplifier circuit BA5417