What Is Arduino?
Arduino is an open source programmable circuit board that can be integrated into a wide variety of makerspace projects both simple and complex. This board contains a microcontroller which is able to be programmed to sense and control objects in the physical world. By responding to sensors and inputs, the Arduino is able to interact with a large array of outputs such as LEDs, motors and displays. Because of it’s flexibility and low cost, Arduino has become a very popular choice for makers and makerspaces looking to create interactive hardware projects.
Arduino was introduced back in 2005 in Italy by Massimo Banzi as a way for non-engineers to have access to a low cost, simple tool for creating hardware projects. Since the board is open-source, it is released under a Creative Commons license which allows anyone to produce their own board. If you search the web, you will find there are hundreds of Arduino compatible clones and variations available but the only official boards have Arduino in it’s name.
Types of Arduino Boards
Arduino is a great platform for prototyping projects and inventions but can be confusing when having to choose the right board. If you’re brand new to this, you might have always thought that there was just one “Arduino” board and that’s it. In reality, there are many variations of the official Arduino boards and then there are hundreds more from competitors who offer clones. But don’t worry, we’re going to show you which one to start with later on in this tutorial.
Below are a few examples of the different types of Arduino boards out there. The boards with the name Arduino on them are the official boards but there are also a lot of really great clones on the market as well. One of the best reasons to buy a clone is the fact they are generally less expensive than their official counterpart. Adafruit and Sparkfun for example, sell variations of the Arduino boards which cost less but still have the same quality of the originals. One word of caution, be careful when buying boards from companies you don’t know.
Another factor to consider when choosing a board is the type of project you are looking to do. For example, if you want to create a wearable electronic project, you might want to consider the LilyPad board. The LilyPad is designed to be easily sewn into e-textiles and wearable projects. If your project has a small form factor, you might want to use the Arduino Pro Mini which has a very small footprint compared to other boards.
Next, we’re going to focus on our favorite Arduino board which we recommend beginners start with.
An Arduino Uno is a basic Arduino board that many beginners will start with. While it was not actually the first board to be released, it remains to be the most actively used and most widely documented on the market. Because of its extreme popularity, the Arduino Uno has a ton of project tutorials and forums around the web that can help you get started or out of a jam. We’re big fans of the Uno because of it’s great features and ease of use.
For the example I’m showing you’ll only need the Arduino UNO R3 board itself and the required USB cable to transfer the program from your computer to the board.
On the board left of the Arduino logo there’s an LED, short for Light Emitting Diode, a small light, with the letter L next to it.
We’re going to switch it on and off and then look in to making it blink on and off for 2 seconds at a time.
When you first plug your USB cable in to your Arduino and your computer, you may notice that this LED is blinking. Not to worry! It’s the default program stored on the chip. We’re going to override this.
The USB cable powers the device. Arduinos can run standalone by using a power supply in the bottom left of the board. Once you’re done programming and don’t require it to be constantly connected to your machine you can opt to power it separately. This is entirely dependant on the use case and circumstances you want to use the device in.
Download Arduino Software
You’ll need to download the Arduino Software package for your operating system from the Arduino download page.
When you’ve downloaded and opened the application you should see something like this:
Take some time to look around and get comfortable with it.
This is where you type the code you want to compile and send to the Arduino board.
- Menu Bar: Gives you access to the tools needed for creating and saving Arduino sketches.
- Verify Button: Compiles your code and checks for errors in spelling or syntax.
- Upload Button: Sends the code to the board that’s connected such as Arduino Uno in this case. Lights on the board will blink rapidly when uploading.
- New Sketch: Opens up a new window containing a blank sketch.
- Sketch Name: When the sketch is saved, the name of the sketch is displayed here.
- Open Existing Sketch: Allows you to open a saved sketch or one from the stored examples.
- Save Sketch: This saves the sketch you currently have open.
- Serial Monitor: When the board is connected, this will display the serial information of your Arduino
- Code Area: This area is where you compose the code of the sketch that tells the board what to do.
- Message Area: This area tells you the status on saving, code compiling, errors and more.
- Text Console: Shows the details of an error messages, size of the program that was compiled and additional info.
- Board and Serial Port: Tells you what board is being used and what serial port it’s connected to.
The Initial Setup
The code you write for your Arduino are known as sketches. They are written in C++.
Every sketch needs two void type functions,
loop(). A void type function doesn’t return any value.
setup() method is ran once at the just after the Arduino is powered up and the
loop() method is ran continuously afterwards. The
setup() is where you want to do any initialisation steps, and in
loop() you want to run the code you want to run over and over again.
So, your basic sketch or program should look like this:
Now we have the basic skeleton in place we can now do the Hello, World program of microcontrollers, a blinking an LED.
Headers and Pins
If you notice on the top edge of the board there’s two black rectangles with several squares in. These are called headers. Headers make it easy to connect components to the the Arduino. Where they connect to the board is called pins. Knowing what pin something is connected to is essential for programming an Arduino.
The pin numbers are listed next to the headers on the board in white.
The onboard LED we want to control is on pin 13.
In our code above the
setup() method let’s create a variable called
ledPin. In C++ we need to state why type our variable is before hand, in this case it’s an integer, so it’s of type
Each line is ended with a semicolon (
setup() method we want to set the
ledPin to the output mode. We do this by calling a special function called
pinMode()which takes two variables, the first the pin number, and second, whether it’s an input or output pin. Since we’re dealing with an output we need to set it to a constant called
OUTPUT. If you were working with a sensor or input it would be
We do this by calling another special method called
digitalWrite(). This also takes two values, the pin number and the level,
HIGH or the on state or
LOW the off state.
Next we want to compile to machine code and deploy or upload it to the Arduino.
Compiling the Code
If this is your first time you’ve ever compiled code to your Arduino before plugging it in to the computer go to the Tools menu, then Serial Port and take note of what appears there.
Serial Port menu previous to Arduino being plugged in
Once you have selected your serial or COM port you can then press the button with the arrow pointing to the right.
Arduino Software with button highlighted
Once that happens you should see the TX and RX LEDs below the L LED flash. This is the communication going on between the computer and the Arduino. The L may flicker too. Once this dance is complete your program should be running. And your LED should be off.
Now let’s try and switch it on using the
Press Upload again and you should see your LED is now on!
Let’s make this a little more interesting now. We’re going to use another method called
delay() which takes an integer of a time interval in milliseconds, meaning the integer of
1000 is 1 second.
So after where we switch the LED on let’s add
delay(2000) which is two seconds, then
digitalWrite(ledPin, LOW) to switch it off and