Introduction to Arduino

The Ultimate Getting Started Guide

When I first started with Arduino back in early high school I was amazed by the versatility and power of the platform. Although there are many electronics platforms available today, Arduino is one of the best and a great place to start learning. In my article I will cover some of the basics and history of Arduino. This will form part of a tutorial series suitable for beginners and those looking to learn some programming and electronics. 

What is Arduino?

Arduino is an open source electronics platform that allows makers to create electronics projects using C and a plethora of available libraries. Arduino makes electronics prototyping simple and allows anyone to quickly (relatively speaking) bring their projects to life. It’s also fairly inexpensive and offers a wide range of customizability. Whether you are building a simple circuit to blink an LED or assembling a robot, Arduino is a great choice.

The Boards

Arduino boards come in two main varieties, the original Arduino boards made by Arduino in Italy, and Arduino clones (that technically shouldn’t bear the Arduino branding). Arduino makes a variety of board designs for different purposes at different price points. Third party manufacturers either make the designs at a lower cost, or modify them to offer additional features. Since it is open source, everyone (including you) is free to build their own (without using the Arduino trademark, of course).

A great place to start is the Arduino Uno R3. It was my first Arduino half a decade ago and is still an excellent choice for beginners and experts alike. It features an ATMEL micro-controller running the Arduino Bootloader which allow Arduino code (written in C in the Arduino IDE) to run on it. The Arduino board also includes all the necesary voltage regulator modules and serial converter in one package, making it easy to use. No soldering or complex electronics knowledge is required to get started!

A great choice for beginners. The Arduino Uno includes everything you need to get started. Great for most projects due to its generous amount of pins, 5V logic and low cost.

Chip ATmega328P
Logic Level Voltage 5V
Digital Pins 14
PWM (Pulse Width Modulation) 5
Analog Inputs 6
Connector USB Type B

Similar to the Arduino Uno, but with significantly more pins for larger, more complex projects.

Chip ATmega2560
Logic Level Voltage 5V
Digital Pins 54
PWM (Pulse Width Modulation) 15
Analog Inputs 16
Connector USB Type B

The Arduino Due is a new breed of Arduino. It is based on the ATSAM3X8E chip and has a 3.3v logic level which can be trickier to work with for beginners. It does however run faster and has features such as keyboard emulation. This is largely thanks to its 32bit ARM based processor (the ATSAM3X8E).

Chip ATSAM3X8E (32bit ARM)
Logic Level Voltage 3.3V
Digital Pins 54
PWM (Pulse Width Modulation) 12
Analog Inputs 12
Connector Micro USB

 

Perfect for projects where space is an issue, the Micro comes to the rescue. It is very similar in nature to the Uno except it is smaller and generally requires to be placed in a breadboard or some form of socket to be used. The chip is very similar to that of the Uno (except it integrates the USB serial converter chip into the SOC, wheras the Uno has a standalone FTDI USB to serial converter), and has the benefit of having a few extra pins.

 

Chip ATmega32U4
Logic Level Voltage 5V
Digital Pins 20
PWM (Pulse Width Modulation) 7
Analog Inputs 12
Connector Micro USB

Getting Started

Speaking of getting started, let’s do it! In this series of tutorials I will guide you step by step and show you the basics of Arduino. This includes both electronics knowledge and programming. Think of it like a slightly more complex Lego for electronics. Each of my tutorials will include a comprehensive introduction and parts list. Along with circuit diagrams, code and a video walkthrough I will make sure the process is as pain free as possible. No prior coding or electronics knowledge is required!

Today we’ll be installing the Arduino IDE and making sure our computer is set up to work with the Arduino.

Parts List

Computer (PC/Mac/Linux)

Arduino IDE (click to download)

Arduino Uno (or alternative)

USB Cable

Note: If you are planning on getting started with Arduino I recommend buying a kit. If you wish to support Arduino, consider buying one of their official kits. Alternatively look into the countless available kits on sites like Amazon, they serve the same purpose.

I recommend getting a kit with an Uno R3, a breadboard, LEDs, resistors, A 20×2 display, variable resistors, a light sensitive resistor and at least a temperature sensor. Some kits offer more sensors and other interesting devices like servo motors, feel free to explore!

 

The Process

1. Go to Arduino.org and download and install the Arduino IDE for your operating system. (If you are running Windows be sure you install the appropriate drivers, they should be installed by default on Mac OS).

2. Once installed, open the Arduino IDE and connect your Arduino to your computer via USB

3. Load the blink sketch (Go to Examples>Blink),

4. Ensure you have the proper Board and Serial Port selected by going to “Tools > Board >Uno” and “Tools > Port>COMX”

5. Upload the Blink Sketch to your Arduino and the built in LED should light up

Arduino Anatomy

The Code

Arduino code is made up of two key functions (sets of commands that can be called upon to run a repetitive task) which are used in each Arduino program, commonly referred to as a “sketch.”

“void setup()” is one of the two key functions present in an Arduino sketch. The setup function returns no output (hence the void datatype), it instead runs once when the Arduino is powered on. Here we add code that initializes the pins (sets them as an OUTPUT or INPUT) and other bits of code that we only want to run once on startup.

“void loop” is the main function of any Arduino program and it runs continuously in a never-ending loop. Here we will add the bulk of our code.

Functions (such as setup and loop) contain code thats encapsulated between two curly brackets “void functionName{CODE GOES HERE }” which mark the start and finish of the function. Each line of code must also be followed by a semi-colon “;”

Let’s take a look at the code:

int ledpin=13; //create and define an integer variable, ledpin, and set its value to 13, which will be out led pin

void setup() { // declare the setup function that will run once on startup
pinMode(ledpin, OUTPUT); //set the ledpin, pin 13, as an output
}

void loop() { // declare the loop function that will run continously
digitalWrite(ledpin, HIGH); //set the ledpin (pin 13) to HIGH, turning it on
delay(1000); //wait for one second (1000 miliseconds)
digitalWrite(ledpin, LOW); //set the ledpin (pin 13) to LOW, turning it off
delay(1000); //wait for one second
}

Tutorial / Build Guide

Check out the video for a step by step introduction to Arduino and installation tutorial. It is important to have everything set up correctly as the following tutorials will build on this one.

Conclusion

Congratualtions! You made it through the first tutorial and are now ready to start your first Arduino project. Click to start the next tutorial.

Downloads and Resources

 

Download Arduino Sketch (ZIP)

Board Comparison

 

More Great Electronics and Programming Tutorials

Arduino 02: Digital Inputs

Arduino 02: Digital Inputs

Last time we looked at how to use Digital Outputs in our projects, today I will be going over digital inputs. At a basic level, digital inputs allow us to add buttons and switches to our projects. I'll also cover "if" statements and button debouncing. Let's get...