Fun with Linux and Hardware -- notes
Tiny board with an Atmega AVR CPU. Open-source hardware, $30
(less for generic copies or if you make your own).
Doesn't run Linux, but can be programmed from Linux easily.
- Arduino Uno: current base model. Start with an Uno if you're not sure.
- Generic copies of Uno or its predecessors (Duemilanove, Diecimila, etc.)
Slightly cheaper, same form factor.
- Mini, Nano,
tiny versions for embedding into projects. Typically need a separate
larger, faster processor, more I/O pins, etc.
- ... etc!
Get the Arduino IDE:
Do this even if you prefer command-line development: you'll need the libraries.
tar xvf arduino-1.0-linux.tgz
The IDE is a Java app. To run:
If the IDE doesn't see a serial port, there could be a permissions problem.
Check to see whether /dev/ACM0 (Uno) or /dev/ttyUSB0 (earlier Arduinos)
exists, and whether it's readable and writable by you.
On Ubuntu, you may need to be in the "dialout" group.
If you prefer not to install Java or prefer command-line development,
unpack the Arduino tarball (you'll need the libraries) then
follow the instructions (and grab the sample Makefile) on my
command-line development page. Most Linux distros have all the packages
Many Arduino projects use Processing
for graphical output. It's a programming language built on top of Java,
which can be used from its own IDE or from Java libraries.
I haven't used Processing much myself. But check out the cool example on the
There's a related project called Wiring
intended to make it easier for artists and designers to drive
microcontrollers like the Arduino. The Wiring website also has lots
of beginner tutorials on basic electronics. Again, I don't have any
personal experience with this (yet) but it might be worth checking out.
There are actually three Arduinoscope projects:
They all use Processing, which you'll have to download separately
(it's a Java app) except for Arduinoscope, which comes with its own
copy of the Processing libraries and is easier to run than the other two.
However, Arduinoscope has a bug: it doesn't work with the Arduino Uno
(the current model) because it tries to open /dev/ttyUSB0 instead of
/dev/ACM0. So to use it with an Uno, you have to make a symlink, as root.
Or fix the line in SimpleSerialArduinoscope.java that does
port = new Serial and then figure out how to recompile it.
If you figure that out, please tell me.
Meanwhile, I'm working on a Python version:
It's still pretty crappy, but it'll get better.
See the Arduino shield list
for a full scary-long list!
Some common shields:
motor/servo, networking (XBee, ethernet or wi-fi), data logging, GPS,
sound/music, voice recognition, simple LCD displays, LCD touchscreen,
gaming, LED arrays, gaming.
Of special interest: proto-shields that offer space for a breadboard
and make it easier to prototype simple circuits.
My first Arduino came with a proto shield and mini breadboard; I
probably wouldn't have thought to buy one on my own, but since I have
it, I use it for everything and would hate to be without it.
Tips on driving motors
I mentioned my motor troubles in my talk. I'm planning a long blog article
on this soon, but let me summarize the options here:
- Don't drive a motor directly from an Arduino. It will spin if there's
no load on it, but as soon as you add load, you'll pull far more current
than an Arduino can handle (the Arduino's
maximum is 40ma per pin, 200ma maximum total for all pins; a typical
small brushed motor can easily pull more than an amp) and you may fry
- All Arduino-oriented shops sell "motor shields". Pay attention to
the amp rating -- some of them can't drive much load.
- When I thought my Freeduino motor shield was too wimpy to drive my
little truck (it has a 1 amp max), it turned out it was actually a
battery problem. Using a beefy lithium-polymer battery made it work.
- The hardcore experts on #arduino and from the Linux Astronomy booth
mostly build their own H-bridge circuits; I haven't done this myself, but
one that was recommended to me.
- Electronic Speed Controllers (ESCs) sold for radio controlled airplanes
are cheap and can drive quite high current. Since they're designed to plug
in to an R/C receiver, you talk to them using the Arduino Servo library.
But you have to figure out their arming sequence, and they can only
drive a motor in one direction.
Driving other high current devices (besides motors): for alternating
current (like blinking a desk lamp, or turning on your computer at a
particular time of day) I recommend the
Very easy to use and I haven't seen any other product like it -- it'll
save you a lot of time. For high current DC, Freetronics just introduced
something called the NDRIVE:
N-MOSFET Driver / Output Module that looks pretty useful for $7
if you don't want to hassle with building your own transistor circuits.
Electronics parts you want
- A multimeter (a cheap $10-15 one is fine, nothing fancy)
- A solderless breadboard (one big one, or several small ones)
- Some wire pieces (solid core, around 20-22 gauge), stripped.
You can buy pre-stripped wire (more expensive), or buy a spool or two
and strip them.
- A wire stripper: I went years using an x-acto knife, scissors or
other techniques because the cool guys I knew said they did it that way.
Don't believe them. I bought a real wire stripper recently and it's changed
my life. And it cost maybe $6.
- Some LEDs, 'cause lights are pretty.
- Some resistors -- an assortment from Radio Shack or Fry's.
- A couple of switches and potentiometers -- that's a fancy word
for a variable resistor
- Eventually you'll want some capacitors, transistors, diodes ...
but you can wait on that 'til you actually have a need.
If you do buy these, KEEP THEM IN LABELED BAGS or compartments in
a fishing tackle box. It's hard to identify these parts after the fact
and they often aren't labeled in any clear way.
- A soldering iron. A cheap one is okay to start; it'll die after
a year or so and by then you'll know if you want to replace it with
a better one. A fine tip, or replaceable tip, is nice to have.
- Some sort of battery or power supply to power your stuff -- Arduinos
run well off anything from about 5 to 9 volts. You can power the Arduino
off your computer's USB cable, but eventually you'll want to be able to
power circuits separately from the Arduino. Personally, I have a
cheap wall wart from Fry's with a dial that goes from 4.5V to 12V
(for Arduino projects I use 6v and 9v), and a 9v battery holder, both
with the right plug for an Arduino (2.1mm barrel plug, center positive,
though I think a 2.5mm will also work).
A holder for 4xAA or 4xAAA would work just as well as one 9v.
Get a barrel jack the same size, while you're buying connectors, so
you can use your power supply with your breadboard as well as
plugging it into your Arduino.
More info on my demos
Source code for the projects I presented:
Akkana's Arduino code.
I've blogged about most of the projects: see the
Arduino tag on
my Shallow Thoughts blog.
I haven't blogged the details of the shark yet (too busy working on
the talk!) but check back: I've uploaded the source code (as of Monday
morning) and will try to write the blog entry in the next few weeks.
Places to buy parts
- Good selection of Arduino models, sensors, displays, and kits,
with great tutorials and documentation
- Great source for sensors, radio gear and other parts.
- O'Reilly MAKE store, huge selection of kits and parts
- I just heard about them this year at SCALE: the Linux Astronomy folks swear by
them and I trust them, so I'm going to check them out.
- No personal experience, but I've heard good things about their
Diavolino, a cheap Arduino clone with FLAMES
- Seeed Studio
- I know nothing about them, have just seen links to them a few times
- Lots of other stores, too many to list
- Even Amazon has electronics and Arduino parts!
Native Linux solutions (ARM based, running Linux natively)
I didn't have time to cover these in the talk, but sometimes you want
something with a little more power.
Most of these devices (except plug compters) have some digital I/O
pins; none of them have analog input like the Arduino.
- Plug computers: about $100, ARM 5/Marvell hardware;
relatively tamper-proof case;
see my Plug computers
page for lots of notes and links. Really not useful for controlling
hardware, but okay as something like a router.
- Beagle board: bare-bones Linux board, about $150
Beagle Bone is less expensive, $89
Related product: Gumstix.
- Chumby: native Linux, open source hardware; clunky but good for parts.
Includes a screen. $130-150, but look for sales and you can pick one
up for under $150.
- Raspberry Pi: bare-bones Linux, ARM 11 processor for $25 - $35.
Unfortunately it's still vaporware.