The Arduino Inventor's Guide (6 page)

ADDITIONAL RESOURCES ON BASIC ELECTRICITY AND ELECTRONICS

If you’re eager to learn about electricity and electronics in more detail, we highly recommend you check out the following books:


Basic Electricity
by the Bureau of Naval Personnel (Dover Publications, 1970)


Arduino Workshop
by John Boxall (No Starch Press, 2013)


Getting Started in Electronics
by Forrest M. Mims III (Master Publishing, 2003)


Practical Electronics for Inventors, 4th edition
by Paul Scherz and Simon Monk (McGraw-Hill Education, 2016)

1
Getting Started with Arduino

This project covers everything you need to get your Arduino up and running! We’ll introduce the hardware, show you how to install the programming environment, and help you make sure everything works by loading a simple program. At the end, you should have your own blinking light and the excitement to move on. Let’s go!

MATERIALS TO GATHER

You’ll need the following hardware (shown in
Figure 1-1
) to complete this project:

• One SparkFun RedBoard (DEV-13975), Arduino Uno (DEV-11021), or any other Arduino-compatible board

• One USB Mini-B cable (CAB-11301 or your board’s USB cable)

• One LED (COM-09590, or COM-12062 for a pack of 20)

FIGURE 1-1:
Required components

ABOUT THE ARDUINO

An
Arduino
(pronounced är·də’wēn·ō or “arr-dween-oh!”) is a small programmable device that can add smarts to nonintelligent things. You can use an Arduino to run robots, create LED art, and even act as a handheld gaming console. In this section, we’ll go into more detail on what the Arduino is and how it can change the way you think about the world around you.

An Accessible Hardware Platform

An Arduino is like a small computer. You can program it using very simple instructions, and you can power it with just a few AA batteries. What makes an Arduino really different from a regular computer is that it uses a
microcontroller
, rather than a CPU, to process information and take action. This small chip acts as the brains of your project, and it can receive input from sensors (like light detectors, temperature sensors, or buttons) and output signals to control LEDs, motors,
buzzers, and more. An Arduino board like the one in
Figure 1-2
has all of the supporting components and circuitry to make a micro-controller work.

FIGURE 1-2:
The Arduino Uno is an open source, programmable electronics platform for hobbyists.

The programming language used for the Arduino is essentially a version of C/C++. The programming environment is the
Arduino IDE (integrated development environment)
. The team that developed it bundled it with many prewritten functions and libraries to simplify the process of writing code to interface with hardware. For example, these libraries take the multiple lines of code required to turn on an LED and simplify them into a single instruction!

About the SparkFun RedBoard

There are many officially Arduino-branded boards, but since the platform is
open source
(meaning the source hardware design and software are available for anyone to look at and modify), there are also many Arduino derivatives, clones, and compatible boards. The board designs are all licensed under a Creative Commons Attribution Share-Alike license, and the Arduino FAQ (
https://www.arduino.cc/en/Main/FAQ
) states that anyone is “free to use and adapt [these designs] for your own needs without asking permission or paying a fee.” Derivative boards work with the same programming environment as an official Arduino, but often the hardware has been tweaked or modified in some way.

The SparkFun RedBoard, pictured in
Figure 1-3
, is an Arduino-compatible derivative board. It is based on the Arduino Uno design but has a more stable USB interface and uses a USB mini connector instead of the Type-A connector. Otherwise, it is exactly the same as the Uno, with the same size and shape.

FIGURE 1-3:
The Arduino-compatible SparkFun RedBoard. Notice how its shape matches up with the Arduino Uno in
Figure 1-2
.

The RedBoard is the go-to Arduino board here at SparkFun and has a few key components that you’ll need to know in order to navigate the first few chapters of this book. We have labeled each term for you in
Figure 1-3
.

ATmega328 microcontroller
The square black chip in the middle of the board. It is the brain of the Arduino.

Header pins
The tiny metal legs on the microcontroller, which let you read input and send output. They are accessible through the four sets of black headers on either side of the Arduino. They are numbered and labeled for specific uses. The pins you’ll care about most are those labeled
Digital
(0–13),
Analog In
(A0–A5), and
Power
.

Mini-USB port
This is how you send code to and communicate with the Arduino. You can also power your board using the USB port for most applications in this book. If an external power supply is needed, we’ll be sure to point it out.

Power LED
This LED is an indicator to show that the Arduino is powered on. If you ever have a short circuit on your board or a bad power connection, this indicator will not turn on.

TX/RX LEDs
These LEDs blink when data, such as code or numbers, is being passed back and forth between your Arduino and your laptop.

Onboard LED 13
A debug light. If you’re plugging your Arduino in for the first time, LED 13 should blink once per second. It’s connected to pin 13 on the Arduino.

External power jack
A barrel jack port next to the USB port. The Arduino takes 5 V of power, though you can safely supply the Arduino a voltage between 7 and 15 V without damaging your board. A chip on the Arduino scales this input voltage down to 5 V for the electronics and circuitry to work properly.

Like all Arduino-compatible boards, you’ll program the RedBoard with the Arduino IDE.

INSTALLING THE ARDUINO IDE AND DRIVERS

You should install the Arduino IDE before plugging your RedBoard into the USB port for the first time. To install the Arduino IDE, go to
http://www.arduino.cc/download/
. Select the appropriate version for your computer’s operating system, and click the link to download (
Figure 1-4
). You’ll be asked whether you’d like to make a contribution; the development and maintenance of the Arduino IDE rely on the help and contributions of the community that uses it.

NOTE

If you’ve already plugged in your board, that’s not a problem—you may just need to restart your computer after the installation is complete for the drivers to work properly.

FIGURE 1-4:
You can use the online IDE or download the latest version for your operating system.

Even if you already have the IDE installed, we recommend downloading and installing the latest version. The Arduino IDE is continuously being updated and improved, and it’s best to have the newest release. The examples in this book use IDE versions 1.8.1 and later.

NOTE

If you like to be on the bleeding edge of software, the Arduino Downloads page also provides nightly builds that preview the next release. For this book, however, we recommend using the latest stable release.

The Arduino website also provides an online platform called Arduino Create, which includes a web-based code editor. It allows you to program your device through your web browser and share and view projects with others online. As of the writing of this book, it is supported only on Windows and OS X.

Whether you choose to use Arduino Create or the downloaded IDE, follow the directions online to run the installation process.

Installing on Windows

If you’re working on a Windows PC, we recommend downloading the Windows Installer version of Arduino. Download this file, open it, and click
Run
. This will bring up the Installation Options dialog (
Figure 1-5
).

FIGURE 1-5:
Installation Options dialog for Arduino. Make sure that USB drivers are selected!

Check the
Install Arduino software
box along with the other options, or you’ll have to install the drivers separately. Then, tell the installer where you’d like to install Arduino (we recommend accepting the default directory), and click
Install
.

Once you begin the installation process, have a snack or a cup of coffee, because it could take a few minutes to complete. Depending on your version of Windows, you might again be asked if you want to install drivers and if Arduino LLC is trusted, as pictured in
Figure 1-6
.

FIGURE 1-6:
In Arduino we trust!

Other books

Drag-Strip Racer by Matt Christopher
Playing with Fire by Graziano, Renee
Halo: First Strike by Eric S. Nylund
Love Love by Beth Michele
Root of His Evil by James M. Cain
Dreams of Origami by Elenor Gill
Ugly Girls: A Novel by Lindsay Hunter
Pig City by Louis Sachar