Friday, 27 January 2023

TRL-Exercise3m

#Library from gpiozero import LED, Buzzer, Button from time import sleep from signal import pause import tm1637 #Component setup green_led = LED(18) red_led = LED(14) anti_spam_led = LED(7) buzz = Buzzer(25) button = Button(24) display=tm1637.TM1637(20,16) #Function def activate(): if anti_spam_led.value == 1: pass else: anti_spam_led.on() greenman() def greenman(): print('Button was pressed') sleep(10) red_led.off() green_led.on() sleep(10) for counter in range(5,-1,-1): green_led.blink(on_time=0.5, off_time=0.5, n=1) buzz.blink(on_time=0.5, off_time=0.5, n=1) display.set_values([' ',' ',' ',counter]) sleep(1) green_led.off() red_led.on() anti_spam_led.off() display.clear() print('Waiting for Next Button Press') #Algorithm red_led.on() anti_spam_led.off() display.clear() print('Program Started') print('Waiting for button to be pressed') button.when_pressed = activate pause()

No comments: