Skip to content
Tristan edited this page Oct 8, 2019 · 7 revisions

pigpiod

Examples

require "pigpio"
include Pigpio::Constant

pi = Pigpio.new

unless pi.connect
  puts "Unable to connect to the pigpiod daemon."
  puts "Maybe you need to run: sudo pigpiod ?"
  exit -1
end

led = pi.gpio(17)
led.mode = PI_OUTPUT
led.pud = PI_PUD_OFF

trap "SIGINT" do
  puts "Exiting"
  led.write 0
  pi.stop
  exit 130
end

loop do
  led.write 1
  sleep 1
  led.write 0
  sleep 1
end
Clone this wiki locally