RAD

Get Version

0.2.0

→ ‘Ruby Arduino Development’

What?

RAD is a framework for programming the Arduino physcial computing platform using Ruby. RAD converts Ruby scripts written using a set of Rails-like conventions and helpers into C source code which can be compiled and run on the Arduino microcontroller. It also provides a set of Rake tasks for automating the compilation and upload process.

Demo: 'Hello World'

Here's a basic demo of RAD in action. In this movie, we'll write, compile, and upload the universal physical computing 'Hello World': a single flashing LED.

Note: This movie was made using an old version of the Arduino board which required a hardware reset before being able to accept a new sketch. More recent versions of the board don't have this requirement and hence as of version 0.2.0, RAD no longer prompts for reset when running 'rake make:upload' (thought the option is still available for older boards.)


Why?

While duplicating the functionality of the well-designed Arduino software interface in Ruby may seem like an odd or redundant goal, RAD has further ambitions! Bootstrapping the ability to write microcontroller code in a high level dynamic language like Ruby could greatly ease the creation of all the luxurious development aids the users of such a language have come to expect: developer testing, platform independence, easy metaprogramming, etc.

Installing

$ sudo gem install rad

You’ll also need to have the Arduino environment installed, which you can get from the Arduino website. RAD currently requires Arduino 0010, but we try to keep it up-to-date with new Arduino releases.

The Basics

$ rad my_sketch

This command will create a new RAD project directory (my_sketch/) inside of the current directory that contains a blank script in which you can write your own RAD code, as well as a full install of the RAD support infrastructure (in vendor/). A sample ‘hello world’ script in RAD will look like this:

class MySketch < ArduinoSketch
  output_pin 7, :as => :led
  def loop
    blink led, 500
  end
end

Once your code is written, your relevant local configuration properly setup in config/hardware.rb and config/software.rb, and an Arduino with the corresponding circuit (a 220ohm resistor and an LED wired in series between Arduino pin 7 and ground) is connected to your computer via serial, run:

$ rake make:upload

This will:

The Arduino API

Most of the Arduino software API should be working correctly at this point. Documentation for the Ruby versions of the methods is forthcoming, but it is mostly what you’d expect: methods with identical names and arguments to their Arduino counterparts with the exception of using ‘true’ and ‘false’ for HIGH and LOW.

Demo: Serial Communication

To demonstrate some of the more advanced features of RAD, here's a movie showing how to program the Arduino to listen to serial communication from a computer.

Note: The same comment from above applies here about the hardware reset. Also, extra points are available if you recognize the logo on the flag in the video.


RAD Needs You!

All the many discipline-crossing skills required for a project like RAD make for lots of opportunities to help out: Have you written lots of sketches exploring the obscure depths of the Arduino library? Do you run the Arduino development tool chain on an obscure (i.e., non-OS X) platform? Do you develop for other AVR or PIC microcontrollers? Are you a C/C++ ninja? Or even C/C++ competent?

There’s lots to do.

If you’re looking for a place to dive in and don’t know quite where, email Greg. If you want to start by taking a log at the code, the trunk repository is svn://rubyforge.org/var/svn/rad/trunk for anonymous access.

License

This code is free to use under the terms of the GPL 2.0 license, just like the Arduino software library itself.

Contact

Comments, questions, heckles, attacks, praises, and, (most especially) patches and contributions are welcome! Send email to Greg Borenstein.

Dr Nic, 18th November 2007
Theme extended from Paul Battley