Last active
August 29, 2015 14:04
-
-
Save justinlyman/9a4c08da7e07ac37bda6 to your computer and use it in GitHub Desktop.
URUG group 2 Raspberry PI soccer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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