This website was originally written in Ruby and hosted on the Raspberry Pi. It's now archived at GitHub for posterity!

WiringPi Serial And Shiftout

Gordon strikes again, releasing a new WiringPi which not only includes the ShiftOut functions I was attempting to add, but also a whole delightful library of Serial goodness.

I've rolled both of these things into a new version of the WiringPi gem, which has also undergone some significant architectural changes favouring a more Object Orientated design. I've incremented the major version to reflect this.

To use GPIO functions you should create an instance of the WiringPi::GPIO class:

require 'wiringpi'
pin = 1
io =

And to use Serial functions, use the Serial class:

require 'wiringpi'
s ='/dev/ttyAMA0',9600)
s.serialPuts('Hello world!')

I've also wrapped up GPIO.shiftOut with an handy, more Ruby-friendly function shiftOutArray. This takes an array of 1s and 0s and shifts them out as bytes automatically.

Full source for WiringPi-Ruby is available on GitHub and I've pushed up Gordon's WiringPi library itself for those interested in contributing to the code.

« Back to index Posted on 2012-07-10 by