Skip to content

Instantly share code, notes, and snippets.

@xunker
Last active August 29, 2015 14:02
Show Gist options
  • Save xunker/194aa382ebfd75ce14a3 to your computer and use it in GitHub Desktop.
Save xunker/194aa382ebfd75ce14a3 to your computer and use it in GitHub Desktop.
Ruby/Raspi ping-pong PoC code
require 'pi_piper'
include PiPiper
trigger_pin = PiPiper::Pin.new(pin: 25, direction: :out)
trigger_pin.off
sense_pin = PiPiper::Pin.new(pin: 18, direction: :in)
while true
sense = sense_pin.read
puts sense
if sense == 0
sleep(0.1)
puts "\ttrigger"
trigger_pin.on
sleep(0.2)
trigger_pin.off
end
sleep(0.10)
end
PiPiper.wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment