Ruby Arduino Development: Physical Computing for Everyone
by Greg Borenstein
In the past few years, microcontrollers -- the chips that control all the beeping, blinking, and
buzzing devices in our world -- underwent a revolution in price and accessibility that parallels the
transformation of microcomputers in the early 70s. Where that first revolution brought the personal
computer this new one brings physical computing: the ability to sense and control the physical world
as easily and cheaply as today's PCs process and store information.
The most useful product of this revolution is the Arduino development board. The Arduino combines a
hardware design that emphasizes easy experimentation with a set of intuitive software libraries that
mask many of the ugly details of microcontroller work. Just as the early personal computers offered
information processing tools to diverse new groups, Arduino opens physical computing to artists,
social workers, scientists, and even simple web programmers who lack electrical engineering degrees.
The Ruby Arduino Development project attempts to extend these virtues by bringing the beauty and
power of Ruby to the Arduino platform. RAD compiles Ruby scripts for execution on the Arduino. In
addition to the syntactic elegance and simplicity gained by getting to program in Ruby instead of
C++, RAD provides a set of declarative Rails-like conventions and helpers that reduce boilerplate
and simplify often-byzantine hardware APIs. Further, RAD takes advantage of Ruby's dynamic nature to
offer sophisticated tools unavailable in the default Arduino distribution such as a testing
framework and a graphical simulation environment (built with _why's Shoes GUI toolkit).
In this talk I'll conduct a comprehensive tour of RAD. Starting with the obligatory physical
computing 'hello world' of blinking a single LED, I'll progress through increasingly sophisticated
demonstrations including serial communication, inline assembly, movement detection, temperature
sensing, and motor control. Lights will blink, things will spin, music will play.
I'll proceed to describe some of the design challenges RAD faces in integrating a diverse set of
technologies (including RubyToC, Shoes, Rake, Makefiles, and avr-gcc) as well as balancing the
constraints of concise compilation output that fits the Arduino's minimal program memory with the
virtues of higher-level abstractions and rich interfaces that make a friendly environment for newbie
hardware hackers.
I'll end with a call of encouragement. As a newcomer to electronics myself, RAD lets me build on the
basis of my existing Ruby chops to create playful and useful projects even with very limited
knowledge of the intimidating world of data sheets, circuit diagrams, and long-forgotten physics
lectures. If I can build cool physical computing projects, you certainly can too.
About Greg Borenstein
Greg Borenstein is the co-founder of Grabb.it, a startup working to make all the music on the web
findable and useful. He is the author of a number of open source projects including RAD
(rad.rubyforge.org), a framework for programming the Arduino open source physical computing platform
in Ruby, and Couch Engine (github.com/atduskgreg/couchengine), a CouchDB-resident web framework. In
his spare time, Greg plays indie rock and organizes PDX Pop Now!, a free all-ages local music
festival and non-profit organization in Portland, Oregon. Ruby was the first programming language he
ever learned.