Arduino: What’s It Good For?
An Introduction to the Arduino Platform
What is the Arduino platform, and why is it so great? If I could boil the answer down to one sentence it would be this: Arduino makes building cool electronic gadgets easy.
What is it really, though? Basically, it’s a tiny computer called a microcontroller. A microcontroller is an extremely basic computer that can be used as a part of an electronic circuit so it can control the other components it’s connected to. The key is that it’s programmable. You can program instructions onto it, and based on those instructions it will control the circuit accordingly. For example, you can do something as simple as blinking an LED in a certain pattern, or something as complex as controlling a robot.
Microcontrollers have already been around for a long time, though. What makes the Arduino so special is the entire Arduino platform. It’s not just a microcontroller. On the hardware side, Arduino boards combine the microcontroller with a set of output pins to send power to other electronic components, and a set of input pins to read power levels from other devices. On top of that, it comes with a convenient USB input as an easy way to send programming instructions and power the board. There’s a little more to the board than that, but those are the important parts.
On the software side, the Arduino platform also consists of its own IDE, where you can program the board using a set of C/C++ functions. This is one of the biggest advantages, because typically you would program a microcontroller with a very low-level language, such as assembly. You don’t even need to learn the entire C language — you can already do a whole lot with just a few basic functions. You can also send data from the Arduino board to the IDE to, for example, see a live graph of the ambient noise level in a room. Sending a program to the board is as easy as clicking one button.
Altogether, what this means is that someone with no prior knowledge of electronics or programming can already start designing and building their own basic gadgets within just a few hours. And with some more training they can design things that would have otherwise required months or years of education. As a result, some of the more creative types who wouldn’t have otherwise invested the time and energy into learning about electronics and programming are now able to turn their ideas into reality.
Here are just a few examples of other people’s Arduino projects shared on Instructables.com:
Create your own 8x8x8 LED Cube 3-dimensional display! We believe this Instructable is the most comprehensive step-by…www.instructables.com
How’s the world feeling right now? This box tells you. Powered by: an Arduino, a WiFly wireless module, an RGB LED…www.instructables.com
This tutorial will show you how to build a jacket with turn signals that will let people know where you're headed when…www.instructables.com
A Simple Example
To give you a rough idea of how an Arduino project is made, let me present a simple example (I’m assuming some basic programming experience). The wiring is as simple as possible: one side of an LED is connected to the pin labelled “13”, and the other side is connected to a “ground” pin. On the programming side, we’ll make the LED blink in a very specific pattern: 3 short blinks followed by a one second pause…and repeat, forever.
Every Arduino “sketch” (the Arduino IDE’s name for a project) typically contains three parts: declarations, a setup() function, and a loop() function. First you declare any variables and constants. Then you put any setup code that needs to run before anything else in the setup() function. The bulk of the code goes inside the loop() function, which will loop endlessly as long as the Arduino is powered.
Let’s start by declaring a constant:
This allows us to refer to pin 13 as “LED” for clarity. Next we write our setup code:
This designates the LED pin (13) as an output pin. Most of the Arduino board’s pins can be designated as either output or input pins. Output pins will send power through electronic components, and input pins will receive power levels that can be read by your code.
Then comes the real work:
As I mentioned before, this code will repeat indefinitely. First we have a for loop set up to repeat 3 times. Inside the for loop we have two occurrences of the digitalWrite() function. This function takes two arguments: a pin, and one of two possible power levels. “HIGH” will send the maximum possible power level (5 volts), and “LOW” will send no power. These basically work as on and off switches (analogWrite() is a another available function, which allows you to send different power levels). We also have a delay() function, which will cause the program to pause for the specified amount of milliseconds.
So the entire sequence of the for loop is:
- Turn the LED on
- Wait for 1/10th of a second
- Turn the LED off
- Wait for 1/10th of a second
After this repeats three times, we call another delay() function that pauses the program for another second. Then, the entire loop() function repeats the whole thing again…and again, forever and ever.
The last step to get the code to run is to connect the Arduino to your computer with a USB cable and press the “Upload” button in the IDE. In a few seconds, your LED will start blinking in the exact pattern we specified!
That was, of course, about as simple as you can get with Arduino programming. You can take things to the next level by using input pins to make an interactive project that responds to input from, say, buttons, sound, or light. There are a plethora of projects posted on the Internet along with detailed instructions. And with a little bit of practice, you can start designing your own contraptions — and the possibilities are endless.