Just got back from this month’s ORUG, where Matthew Williams gave a presentation on using Ruby to control an Arduino. Matt is a very natural speaker, and the presentation was great. He even demoed a bartending robot he built, which should be featured on Make very soon.
I took notes during the presentation, and they are as follows, with links where possible.
Physical Computing with Ruby and Arduino
Arduino is an open-source board
There’s Bluetooth Arduino boards
There’s an Arduino board that was developed in a circular shape. People have combined this with conductive thread and sewn it into clothing. Someone even integrated this with some LEDs into their clothing and made a shirt with turn signals for biking.
Matt showed a video of a Wii nunchuck integrated with an Arduino, hooked up to some servos, and made a robotic puppet that works just by moving the nunchuck (not the control stick, just the accelerometer motion).
There’s also a YouTube video with someone who built a 1-wheel Segway-esque skateboard. Matt claims there are only about 50 lines of code controlling this device.
Matt says that the Arduino Google Group is fantastic.
[Tim: The Arduino IDE looks a *lot* like the Processing IDE (the Java-based graphics language).]
RubyToC – Ruby To C project; converts your Ruby code into C++, then compile it into Arduino bytecode. Then, there are Rake tasks which will load it onto the board for you. Most — but not all — of the Arduino API has been ported to Ruby.
digitalWrite | digitalRead
analogWrite | analogRead
serial_print | serial_read
He mentions a slick trick for controlling the 7-segment LED displays. Since there’s 7 segments, you need to set 7 values separately, OR just create an array of those, and set them all with a single assignment.
Coming soon to RAD framework:
- Arduino Simulator (for testing)
- Better RubyToC support (there’s a few hacks required because ToC isn’t perfect)
- More “out of the box” support
- OLED displays
Shields are boards that can be plugged directly on top of the Arduino that add major new functionality.
- NYCResistor.com built a device that has sliders, like an audio mixing board. I bet it goes up to 11.
- 802.11 addons also exist
- Controlling motors
- There’s a $30 “ping” sensor from Radio Shack that detects distance in *inches*. Basically, you can add sonar to your Arduino.
- OLED touchscreen
- Pin visualizer — lets you debug pin outputs easily, shows you the voltages coming out of the board. Great for debugging. No one is sure if the code for these (debugging) takes up space on the Arduino in place of your code
Cheaper versions are available, but they either have components removed, or you must assemble it yourself
Make published a “get started with Arduino” kit, about $80, includes project info, the Arduino, extra parts. Most of the parts required for the project are included in the kit.
Barduino – DRINK MIXING ROBOT (created by Matt, who is clearly demonstrating his aptitude as a proper geek)
He used windshield washer pumps, $9/each
Matt created a DSL for describing drinks
drink ‘Screwdriver’ do
serve_in ‘Highball Glass’
Matt mentioned a hack, some functions that accept only one param will get converted (by RubyToC) to functions that accept none, so, the following line fixes it
foo = pump + 0 /* This is the fix */
For more Ruby Arduino…
RubyConf 2008, Friday, 10:25 – 11:05, Room 3
Greg Borenstein — author of the Ruby Arduino framework — is presenting
Can you “brick” an Arduino?
Not via code, but you could put too much power into it and fry it. Matt thinks there’s a little surge protection on it.
Can you sync Arduinos?
He’s seen something like it, and thinks that the serial comm lines would make it fairly easy to do.