Arduino is an easy-to-use but powerful platform for developing electronic systems that can interact with the physical world. It consists of a microcontroller board and the software to write programs for the board. In earlier days, microcontroller programming was difficult and usually reserved for professionals. Arduino changed that forever by simplifying the art and allowing just anyone to take it up. Arduino enjoys immense popularity among developers, hobbyists, and students worldwide. In this article, we provide an introduction to Arduino hardware and software. You will find here all the information you need to quickly get up to speed with Arduino, from buying the right hardware to developing your first application.

What is Arduino

The Arduino platform consists of a microcontroller board and the associated IDE (Integrated Development Environment). Microcontrollers are small computers that are much easier to interface with the physical world than regular computers. Microcontrollers have been around for a long time finding diverse applications such as remote controls, washing machines, game consoles, gas meters and industrial control systems to mention a few. Microcontroller programming was not easy and usually reserved for those with a background in Electronics Engineering. Arduino changed that by taking the messy details of microcontroller programming out of the equation.

A microcontroller is a microprocessor that is designed to control the functions of an electronic device or system. A microcontroller chip needs some external components before you can program it. These components are usually assembled on a breadboard when you are developing a prototype. Arduino makes this development much easier by providing a pre-built board with a microcontroller at its heart. The hardware is complemented by the Arduino IDE that you can download for free. The Arduino IDE comes with many libraries and makes it easy to write Arduino programs or sketches, as they are known in the world of Arduino.

Arduino is not one-size-fits-all and a range of Arduino boards is available for different applications. Arduino Uno R3, also shown in the graphic below, is the best for getting started with Arduino.

The components of Arduino Uno board are described below (clockwise from bottom left):

Power Connector: This is used to power your Arduino when it is not plugged into a USB port for power. The power connector can accept voltages from 7 to 12 volts, so the standard 9-volt battery is good enough for powering the board.

TX and RX LEDs: These two LEDs (light emitting diodes) indicate communication between your computer and your Arduino. You can expect those LEDs to flicker rapidly when you are uploading an Arduino program, aka sketch, to the board.

USB Port: The port connects your Arduino to a computer and it is used for powering your Arduino as well as uploading sketches to it.

Reset Button: The button is used to reset the on-board microcontroller

Digital Input/Output: The pins are the primary way Arduino interfaces with external components and systems. The pins are used to both read and write digital data using digitalRead() and digitalWrite() functions.

Power LED: The power LED indicates that your Arduino is getting power.

On-board LED: The on-board LED is internally connected to pin 13 of your Arduino Uno. The LED comes in handy for writing your first sketch as it is already built-into the board and you don’t have to connect any external component.

Microcontroller: The official Arduino Uno R3 board that is based on the ATMEGA328P-PU microcontroller of the Atmel AVR family of microcontrollers. The microcontroller is the heart of your Arduino Uno board.

Analog Input: These pins are used to read analog voltages from sensors using the analogRead() function.

Arduino shields are add-on boards that can be plugged directly on top of the Arduino board in order to extend its functions. For example, the Arduino Uno R3 board does not have networking capabilities. You can add the Arduino Ethernet or Wi-Fi shields to the Uno to connect it to the world. A wide range of Arduino shields is available that enable you to implement almost any project idea you might have without building custom hardware.

Parts List

You may read the article to understand what Arduino is and what it’s capable of, without buying any hardware. But if you would like to create your first Arduino application as described in the article, you will need the following parts:

  1. Arduino Uno R3: The Arduino Uno R3 board is the heart and soul of your project. In addition to the board, you also need the Arduino IDE (Integrated Development Environment) to write programs. The IDE is available as a free download and you will find detailed instructions on how to download and install it, later in the article.
  2. USB cable (Type A to Type B): You may already have this cable lying around somewhere as it is normally used for connecting desktop printers and scanners to computers. The cable will be used to connect the Arduino board to your computer for power and communication.

The Arduino Uno R3 board can be ordered at www.amazon.com/Arduino-UNO-board-DIP-ATmega328P/dp/B006H06TVG/ for around $28. You should also be able to get an Arduino from your nearest distributor. The updated list of worldwide Arduino distributors is available at http://arduino.cc/en/Main/Buy.

Arduino IDE

The Arduino IDE allows you to write programs and upload those to Arduino. You can download the latest version of the Arduino IDE software for Windows at http://arduino.googlecode.com/files/arduino-1.0.5-r2-windows.exe. The IDE is also available for Mac OS X and Linux as well if you happen to use one of these operating systems.Once downloaded, you have to double-click the installer to start installation.

Press the I Agree button.

Press the Next button, leaving all components selected.

Press the Install button to start the installation.

Press the Install button, if you get a dialog box similar to the one shown above.

Press the Close button to finish.

Connect the Arduino board to your computer using a Type A to Type B USB cable. The board will draw power from the USB port on the computer and the power LED (labeled ON) will light up. Windows should also detect the board as soon as it’s plugged in and install the driver automatically. If the automatic installation fails or doesn’t start at all, you can install the driver manually. The driver is located in the drivers folder inside the Arduino installation folder, that is, C:\Program Files (x86)\Arduino in our case. Once the driver installation is complete, one way or the other, you should see a port similar to Arduino Uno (COM3) under Device Manager > Ports (COM & LPT), as shown below.

You can launch the IDE and expect to see the following splash screen for a second or so while the program loads.

You should find yourself at the main application window.

The First Arduino Program

You are all set to write your first Arduino program that will do something very simple like blinking an LED. Despite the simplicity of the program, you will learn how to write, compile, and upload a program to Arduino. The knowledge gained would help you write more complex programs later.

We will briefly describe some of the structural components used in our first sketch. Functions are parts of computer programs with unique names that group specific commands together. Every Arduino program has two main functions called setup() and loop(). The setup() runs only once when the Arduino is powered on. The loop() runs continuously after the setup() has completed. A few other examples of functions used in our program are pinMode(), digitalWrite(), and delay().

Variables are used to store values and can be referenced by an arbitrary name. Variables can be one of many data types like integer. Constants are predefined variables that make programs more readable. For example, when reading or writing to a digital pin, the pin can be set to HIGH or LOW that are both constants.

Comments are used to document your programs in plain language. You can start a line with double slash, and anything that follows on the line is ignored by Arduino IDE. Comments are used to make the program more readable to humans.

The program turns the LED on, waits for half a second, turns the LED off, and then waits for another half second. The cycle keeps repeating until you power down the Arduino or load another sketch to it. Please keep in mind that the on-board LED is actually connected to pin 13 and that’s why we are writing to that pin to make the LED blink. You can simply copy the code and paste into the Arduino IDE.

// pinNumber is an integer variable to identify the pin
int pinNumber = 13;

// the setup() function runs only once when Arduino starts
void setup() {
 // initialize the digital pin as an output
 pinMode (pinNumber, OUTPUT);
}
// the loop() function runs over and over again forever
void loop() {
 // turn the LED on (HIGH is the voltage level)
 digitalWrite (pinNumber, HIGH);
 // wait for 500 milliseconds or half a second
 delay(500);
 // turn the LED off by making the voltage LOW
 digitalWrite (pinNumber, LOW);
 // wait for 500 milliseconds or half a second
 delay(500);
}

After pasting, you have to press the upload button marked with a right arrow to compile the sketch and upload it to the Arduino board.

The on-board LED labeled L should start blinking upon successful upload. Please note that your Arduino board may come pre-loaded with a sketch to blink the on-board LED. If that’s the case, the LED would already be blinking when your power up your Arduino for the first time. You can change delay from 500 milliseconds to 100 or 1000 in order to make the LED blink faster or slower, respectively. That would make you certain that your Arduino is running your sketch and not the sketch that would have come pre-loaded.

It’s up to you to take care of yourself and those around you, when doing Arduino projects. Voltages on the Arduino board itself are well within the safe range but a freshly blown electronic component on the board may be pretty hot. The board is well-built though and you will have to do something really stupid to burn something on it. You should buy the original Arduino and not a knock-off to make sure you are working with a quality product. Also, at no point in your projects should you work with relays and mains power, unless you fully understand what you are doing.

Arduino is not the only microcontroller development platform out there. There are others like the Beagle family by BeagleBoard and the more recent Galileo by Intel. Arduino is by far the most popular; the popularity works in your favor as the range of accessories becomes huge while prices stay low. We would also like to mention the single-board Linux computer called Raspberry Pi. The Pi was never really designed as a development platform but, with a price tag of $35 (more or less) only, a huge number of creative embedded projects have been built around it. If you are interested in learning more about Raspberry Pi, you may refer to our introductory article here.