Rustle is a gem that aims to allow you to control an addressable RGB LED strip in Ruby (using an Arduino as a middleman). Run it on your computer, a Raspberry Pi, or whatever you want! All you need is a strip, an Arduino, and a serial connection.
It's pretty easy.
$ gem install rustle
1. Set up your Arduino
Upload the basic.ino sketch to your Arduino. Make sure that you take a look at the file first and modify it to suit your physical setup.
Gotcha: the Arduino resets itself upon any serial communication. We are currently considering switching to the firmata protocol in order to work around this problem. For now, you will need to place a 10μF capacitor between the
GND pins on your Arduino after uploading the sketch if you want to use Rustle from a static Ruby script.
The sketch itself is still being worked on. Our goal, in the future, is to simply allow you to call
rustle arduino:prepare to automatically generate and upload the sketch (with the number of LEDs, frames per second, etc) to the Arduino using Ino.
2. Connect to the Arduino
The majority of Rustle's actions are performed by calling methods on a receiver's LED strip. First, connect to your receiver:
# Change these params to match your setup. arduino = Rustle::Receiver.new("/dev/[PORTFILE]", num_leds: 60)
3. Throw a party
That's it! You can now control your LED strip with Ruby. Try out some of the following (this might be easier in a Ruby console):
# Adding on to the code from earlier... strip = arduino.strip # Make the strip red strip.to Color.hex('f00') # Make a fancy-schmancy wipe transition to white strip.transition :wipe_to, 2000, color: white
Alternatively, view it on RubyDoc.info.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Add some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request