This is part 3 in my Sunfounder Superkit series.
We’ve blinked it, hooked it to a button, and now for some serious fun: lots of them! This exercise really tests your patience with the breadboard.
(1 LED + 1 resistor + 2 wires) * 8 = 24 things to plug in
Once this was all setup (~15min), it looked great! I was really pumped to start playing around with so many twinkling lights!
So I crack open the python script and start to pipe it into ruby, because Ruby. I get to the line where it sets up the LEDs with
rpi_gpio and what do I find? No multi-pin setup support.
I know what you’re thinking, “Just move on and test it with Python or C already”. Helllllll no! I didn’t make it all this way to have to mangle together some half-baked snake-oil code (in all fairness, the C code is quite nice to work with, and I did try it out before converting this **blush**).
It’s time to pony it up and ride the open source winds into the sunset.
Fortunately, the Ruby documentation on creating extension libraries is really spectacular. With a little fiddling, I was able to get a working multi-pin
GPIO.setup method, and PR submitted. Yay open source!
Before the PR merged, I had to build the gem locally (
rake compile) and reference it using the
gem “rpi_gpio", path: /path/to/local/rpi_gpio in my Gemfile. I'll float by all the gripes I have with developing Ruby extensions and dive right into the goal: a real-life self-made majestic racing marquee!
So, that was a fun ride. The creative corner of my brain came knocking through the wall like the Kool-aid man though. I just have to spin this drab loop into something a little more fun and, dare I say, practical?
Ok, not the most amazingly-fantastic-best-idea-ever, but I'm looking for a small twist to my existing example so I can escape the monotony of this textbook tutorial. With our new lovely Ruby script, we can make some small tweaks and have our LEDs count all the way to two hundred and fifty five (code here to save space).
Impressive, I know, but practical? Well my creativity was oozing today (with this many twinkling lights how could it not!?) and discovered how I might be able to turn this into my new favorite desk toy.
I'm a pretty big fan of the Pomodoro Technique, and since I now made something that can count, I'll likely jack this bad girl up and spin this sweet little counter into a meaningful meter for time spent. A visual Pomodoro Meter if you will.
Or maybe, instead of counting time, it could count the number of PRs I have open on GitHub. So many possibilities!
Well that's all for now folks. I hope you enjoyed the sunset. If you decide to boldly clone this and make something of your own I'd love to hear about it :-)
Tune in next week, where I venture into mutli-colored LED land and a slowly pulsing light show.