Dec-23-2019, 09:17 PM
Hi Larz60+,
Thanks for all your help - it really came in handy. My code works perfectly now:
Birdwatcher
Thanks for all your help - it really came in handy. My code works perfectly now:
from time import gmtime, strftime, sleep import time, datetime from gpiozero import Button from gpiozero import LED import time n = 0 button=[1] red = LED(18) yellow = LED(23) green = LED(24) red.off() green.off() yellow.off() button = Button(25) starttime = time.time() print ("starting") try: while True: currenttime = time.time() elapsed = currenttime - starttime # print elapsed if elapsed >= 7: break if button.is_pressed: n = n + 1 print(n) sleep(0.2) except: pass print ("flashing", n, "times") for number in range(n): red.on() yellow.on() green.on() time.sleep(0.5) red.off() yellow.off() green.off() time.sleep(0.5)Thanks,
Birdwatcher