This post should acquaint you with How to Setup and Program Arduino board. Also, we will learn how to write simple LED blink program. The programming of Arduino is really a piece of cake. We begin this post with a quick introduction of Arduino Uno board. Please note that instead of calling Arduino Uno all the time, I prefer just to call Arduino.
Introduction: Arduino Board
Arduino board is a simple and easy to use electronic prototyping platform. The cool thing about Arduino hardware is that it’s been provided with free Arduino IDE, code libraries and plenty of example projects. Also, we would not have to care much about driver installation. It will be managed by IDE itself while installing Arduino IDE. When we look at Arduino kit it looks very simple with ATmega328 as a central processing unit and few components on board. To follow this complete tutorial you only need Arduino board, USB Type A to B Cable and Laptop/PC. As shown in the picture below.
There are different Arduino derivatives available in market. These all looks physically similar except serial communication chip. The original Uno uses MEGA16U2 chip for serial communication whereas FREEDUINO uses FT232RL chip to communicate over USB. As a beginner, I suggest you to do not worry because despite of differences they still follow same setup and programming procedure.
Features of Arduino Uno:
Crystal Frequency: 16 MHz (external crystal)
Flash Memory: 32 KB from which 0.5 KB used by bootloader (ATmega328)
RAM Memory: 2 KB (ATmega328)
EEPROM Memory: 1 KB (ATmega328)
Operating Voltage: 5V DC
Input Voltage: 7-12V (Powered by either USB or DC Adapter)
Analog Inputs: 6
Digital I/O: 16 (out of them 6 PWM Pins)
If in case, you’re not able to understand these features then feel free to ignore them for a while. Arduino is very easy to get you start and believe me you need not to understand all specifications just to blink LED. Let’s jump right into the programming part of Arduino.
Setup and Program Arduino Board
This video will guide you through step-by-step process of installation, configuration. There are few settings need to confirm such as selecting right COM Port and Arduino Uno board before we upload the sketch.
In the end of this post you will find troubleshoot guide. If in case you face any problem while establishing communication between Arduino and PC/Laptop.
Example: Blink LED with Arduino Uno
This code belongs to built-in example project, Open Arduino IDE –> File –> Examples –> Basics –> Blink. We already have shown in video.
[crayon-5c6abfd4c6e08773371316/] We already explained each and every line of code in the video. This program will blink onboard LED with the delay of 1 second. I recommend you to play with delay() function. You can pass a different value in delay function and observe the effect. Let’s have a look at all the pins and its functions on Arduino. Together there are around 30-pins including Power Pins. Also, there are few of connectors.
I think we don’t need to list functions of each pin on Arduino. They are pretty self explanatory as shown in picture above.
Explained: Arduino Bootloader
In my opinion, there are two things which make Arduino very special among other boards. One is its very simple programming language some people also refers it as Arduino Sketch and the second one, is its built-in Bootloader. Now question is What is this Arduino Bootloader? The answer is, it’s a piece of code or software program that sits onto dedicated portion of memory. Whenever you Power On the board, bootloader is the code that runs first and then user program. Almost all microcontrollers have some form of bootloader but Arduino Bootloader is very special because it makes programming of Arduino like a piece of cake without using any additional Programming Adapter. This means Arduino uses serial USB interface to transfer user program/sketch from PC to Arduino board. This not only saves money but also make programming easy for newbies. Normally this bootloader code takes around 2 KB of flash memory. As Arduino is open source hardware, you’ll get entire source code on official site of Arduino. Usually, every Arduino board comes with pre-loaded bootloader onto ATmega328. As a beginner you need not to do anything with bootloader. But once you are familiar with Arduino System, then you can explore and play around bootloader code.
Troubleshoot Guide for Arduino Board
There may be possibility to face some common errors. These errors most often experienced with Arduino derivates or duplicate boards. We have listed some error messages and their solutions. This will help you troubleshoot while programming Arduino.
avrdude: stk500_getsync(); not in sync : resp=0x00
There are three possible mistake causes to run into this type of error:
- Make sure correct COM port selected
- Make sure driver installation (because Freeduino uses FT232RL).
- Make sure ATmega328 chip is properly inserted into DIP Socket
java.lang.NullPointerException at processing.app.serial.SetDTR
Ser_Send(): write error: sorry no info avail.
If you get this error message, that means you have not selected proper serial port. I recommend you to go ahead and make sure COM Port setting.
avrdude: Expected signature for ATMEGA is…..
This error message appears when you have wrong board selected into the Tools menu. So make sure board selection menu in Arduino IDE.
I recommend you to stay away from cheap Arduino derivates. It’s always better to spend few more bucks and save time. I have tried few of these cheap products and had long frustrating hours to find my way around. In this process very often I have failed to make things work. The same energy invested in programming will give you better payoff. Anyways choice is yours.
This is it for now. I hope now you know How to Setup and Program Arduino board or any other similar board. If you feel Pin functions needed then I will consider adding them into the post. In future posts, we will learn interfacing of various sensors and peripheral chips to build some cool projects around Arduino. Thanks for reading and don’t forget to leave a comment.