Skip to content

Instantly share code, notes, and snippets.

@justinlyman
Last active August 29, 2015 14:04
Show Gist options
  • Save justinlyman/9a4c08da7e07ac37bda6 to your computer and use it in GitHub Desktop.
Save justinlyman/9a4c08da7e07ac37bda6 to your computer and use it in GitHub Desktop.
URUG group 2 Raspberry PI soccer
# Group 2
# Pin 17 Sensor
# Pin 25 Trigger
require 'pi_piper'
include PiPiper
trigger = PiPiper::Pin.new(pin: 25, direction: :out)
sensor = PiPiper::Pin.new(pin: 17, direction: :in)
puts sensor.value
loop do
if sensor.read == 0
puts "Sensor Triggered"
sleep 0.1
trigger.on
puts "Trigger On"
sleep 0.2
trigger.off
puts "Trigger Off"
end
sleep 0.05
end
# after :pin => 17, :goes => :low do
# trigger.on
# sleep 1
# trigger.off
# end
# PiPiper.wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment