Evented GPIO on Raspberry PI with Ruby

1 ยท Aaron Patterson ยท Jan. 17, 2017, 6:24 p.m.
I need to know when my cats are pooping so over the weekend I hooked up a motion sensor to my Raspberry PI. This is the code I used to get an interrupt when the motion sensor turns on or off: require 'epoll' def watch pin, on: # Export the pin we want to watch File.binwrite "/sys/class/gpio/export", pin.to_s # It takes time for the pin support files to appear, so retry a few times retries = 0 begin # `on` should be "none", "rising", "falling", or "both" File.binwrite "/sys/...