On October 10, 2008, I presented on the Ruby Arduino development framework, RAD for the Orlando Ruby Users Group. After two years of attending ORUG, I decided it was time to make my contribution back to the community and that contribution was….
(Photo credit: Anthony Eden)
Barduino is an Arduino based bar monkey implementation. To sum up a bar monkey, it’s typically a computer control drink dispensing system. The Arduino, a very cost effective physical computing platform was the perfect base for the Barduino. And the ability to work with a language I’m comfortable with, Ruby, to write the software that runs on the Arduino made this a relatively simple project. All of this being made possible with the Ruby Arduino Development Framework.
So first off, let’s take a look at the Barduino in action:
So how was this accomplished? You can take a look at the source code over at GitHub.
Here’s the basic breakdown of what the Arduino is doing:
- Verify there’s a glass sitting under the dispense area. This is accomplished with a photoresistor that detects light
- Verify the Arduion has a serial connection for it to receive commands
- Listen for either a “1″ or “2″ being send to the board over the serial line (via the USB port)
- If a “1″ or “2″ is received, call the dispense method pass it the pump it needs to turn on
- Dispense a single ounce of liquid on the given pump and return back to the main loop
So now we have the Arduino programmed and ready to go, but how do we send those characters over the serial port to actually make some drinks? With a domain specific language written with Ruby of course. In the case of the Barduino, you have the Barduino-tender. You build a recipe in a very elegant Ruby like manner and from there, you let the Barduino-tender go ahead and tell the Barduino which pumps to turn on and how many times. So let’s take a look at an example recipe.
drink 'Screwdriver' do serve_in 'Highball Glass' ingredients do 2.ounces :vodka 5.ounces :orange_juice end end
Now that’s all left to do is run that recipe against the barduino-tender and the Barduino will proceed to dispense 8 single ounce shots from the respective pumps. You can take a look at the DSL on GitHub.
So what does the circuit look like that’s driving the Barduino? Here’s a photo, give it a click to head on over to Flickr so you can see what each of the components are.
How about cost? It was very minimal. $34.99 for the Arduino. $9.75 for each pump. And the rest of the parts came from Radio Shack. The total cost of this project was less than $75. And thanks to Mike Wheeler for whipping up the rig for me to mount everything on!
Lastly, big thanks to Gregg Pollack for running the show at ORUG and be sure to check his latest project with partner in crime Jason, EnvyCasts for some of the most well produced screencasts that you’re going to find in the Rails world. Absolutely worth every penny.