The RPi gem now contains methods PinX#lock and PinX#unlock

Example

require 'rpi'

door = RPi.new([4]).pins.first

# lock the door
door.lock 

# unlock the door
door.unlock


Resources