## Stop Target
# Detects the first to hit their target
# Lights appropirate LED for 5,10,15 seconds and ignores other triggers.
from machine import Pin
import time
#Define IO Pins GPIO Number not Pin Number
Left_Target=Pin(0,Pin.IN,Pin.PULL_DOWN)
Right_Target=Pin(2,Pin.IN,Pin.PULL_DOWN)
Left_LED=Pin(4,Pin.OUT)
Right_LED=Pin(6,Pin.OUT)
Short_Time=Pin(18,Pin.IN,Pin.PULL_DOWN)
Long_Time=Pin(17,Pin.IN,Pin.PULL_DOWN)
#Set Display/Delay Time set using On-Off-On switch. Medium (switch off), Short, Long
DisplayTime=10
if Short_Time.value():
DisplayTime=5
if Long_Time.value():
DisplayTime=15
#All Other comment lines for debugging.
#RHS="Right"
#LHS="Left"
#SensorTriggered="SensorTriggered"
#CountCyl=int(0)
#print(Left_Target,Left_LED,Right_Target,Right_LED)
#print(RHS)
#print(LHS)
#print(SensorTriggered)
#print(CountCyl)
while True:
#CountCyl += 1
#print(CountCyl,Left_Target.value(),Right_Target.value())
if Left_Target.value():
#print(SensorTriggered,LHS,CountCyl)
Left_LED.on()
time.sleep(DisplayTime)
Left_LED.off()
if Right_Target.value():
#print(SensorTriggered,RHS,CountCyl)
Right_LED.on()
time.sleep(DisplayTime)
Right_LED.off()
#print ("End")