54 March 2014
■ BY JOE PARDUE SMILEY’S WORKSHOP
In the January and February articles, you were introduced to the Arduino, how to use it to blink an LED, and how to use a breadboard with it to build and
test electronic circuits. This month, you’ll be introduced to
some basic concepts of an Arduino program and how to
use those concepts to keep counts and times so that we
can blink LEDs in programmable patterns.
Program Versus Sketch
The Arduino community calls a program a sketch.
This is because the Arduino was originally written for
artists, but nonetheless, a sketch is a computer program.
We will use both terms without too much regard to
formality. When discussing concepts general to
computers, we’ll probably use ‘program’ and when we are
referring to a specific Arduino program, we might use
‘sketch.’ So, be prepared to see it either way.
We define a program (sketch) as a sequence of
human readable text statements following the rules of a
programming language. This program can be converted
to instructions that a computer can follow to do the sorts
of things a computer does.
A computer program is converted to a sequence of
instructions that a computer understands, then those
instructions can be uploaded to the computer to make it
do what we tell it to do in the program. These programs
are converted from human readable text to machine
readable code by a compiler which is also a computer
program. The process is called compiling, though the
Arduino community calls it verifying (or verify). We’ll also
use these terms both ways.
How Do We Write a Program?
Let’s repeat the above: A program is some text that
follows some rules and can be converted into something
that we can feed the computer to use to make decisions
about what it is to do next. Text, rules, and decisions — we
learn the rules, write the text, then the computer makes
decisions and does something. This is the sequence:
1. We decide what we want the computer to do.
2. We think about how our programming language
rules might be used to get the computer to do our
3. We write a program using the text editor in the
Arduino IDE (Integrated Development
4. The Arduino IDE sends that text to a compiler on
our PC that checks our text against some rules and
then builds something that can be uploaded to the
computer on the Arduino board. The computer on
the Arduino accepts the uploaded data and starts
making decisions about how the Arduino board
processes information and uses the hardware.
This article continues the Arduino 101 series as part of a formal curriculum where
you learn computing and electronics basics much like you'd learn if you took a
standard semester-based introductory course. To help in this, I've started
www.arduinoclassroom.com where each of these magazine articles will be
presented along with laboratories, exercises, quizzes, and a forum. Now, instead
of being a passive reader, you get a chance to have some interaction with other
readers and to talk back to the writer. This series uses an Arduino proto shield and
some electronic components that are available in the Arduino 101 Projects kit that
you can get from the Nuts & Volts Webstore.
The Arduino Classroom
Arduino 101 — Chapter 3:
How an Arduino Program Works