Today in open lab I worked more on the Jeopardy code:
#Adam and Alex # Jeopardy Controller # 3.3v = 1,17, 5.0v =2,4 GND = 6,9,14,20,25,30,34,39 # I/O = 3,5,7,8,10,11,12,13,15,16,18,19,21,22,23,24, # More I/O =26,27,28,29,31,32,33,35,36,37,38,40 import RPi.GPIO as GPIO from time import sleep GPIO.setmode(GPIO.BOARD) ResetButton = 18 SecondRoundButton = 22 readyLED = 5 player1LED = 7 player2LED = 8 player3LED = 10 player4LED = 11 player1Button = 12 player2Button = 13 player3Button = 15 player4Button = 16 GPIO.setup(readyLED, GPIO.OUT) GPIO.setup(player1LED, GPIO.OUT) GPIO.setup(player2LED, GPIO.OUT) GPIO.setup(player3LED, GPIO.OUT) GPIO.setup(player4LED, GPIO.OUT) GPIO.setup(ResetButton, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(StartTimerButton, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(player1Button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(player2Button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(player3Button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) GPIO.setup(player4Button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN) # Your Code Here from time import sleep import threading player1Button.state(["!disabled"]) # Enable the button. player2Button.state(["!disabled"]) # Enable the button. player3Button.state(["!disabled"]) # Enable the button. player4Button.state(["!disabled"]) # Enable the button. t = threading.Timer(45.0) #timer for 45 seconds t2 = threading.Timer(20.0) #timer While ResetButton = True: readyLED = High t.start()#main timer If player1Button = True: t2.start()#mini timer player1LED = High time.sleep(.5) player1LED = Low time.sleep(.5) player1LED = High player1Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. ----------------------------------------------------------------------------------------------------------------------------------------------------- While SecondRoundButton = True If player2Button = True: t2.start()#mini timer player2LED = High time.sleep(.5) player2LED = Low time.sleep(.5) player2LED = High player2Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player2LED = Low If player3Button = True: t2.start()#mini timer player3LED = High time.sleep(.5) player3LED = Low time.sleep(.5) player3LED = High player3Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player3LED = Low If player4Button = True: t2.start()#mini timer player4LED = High time.sleep(.5) player4LED = Low time.sleep(.5) player4LED = High player4Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player4LED = Low ----------------------------------------------------------------------------------------------------------------------------------------------------- Else: player1LED = Low If player2Button = True: t2.start()#mini timer player2LED = High time.sleep(.5) player2LED = Low time.sleep(.5) player2LED = High player2Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. ----------------------------------------------------------------------------------------------------------------------------------------------------- While SecondRoundButton = True If player1Button = True: t2.start()#mini timer player1LED = High time.sleep(.5) player1LED = Low time.sleep(.5) player1LED = High player1Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player1LED = Low If player3Button = True: t2.start()#mini timer player3LED = High time.sleep(.5) player3LED = Low time.sleep(.5) player3LED = High player3Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player3LED = Low If player4Button = True: t2.start()#mini timer player4LED = High time.sleep(.5) player4LED = Low time.sleep(.5) player4LED = High player4Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player4LED = Low ----------------------------------------------------------------------------------------------------------------------------------------------------- Else: player2LED = Low If player3Button = True: t2.start()#mini timer player3LED = High time.sleep(.5) player3LED = Low time.sleep(.5) player3LED = High player3Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. ----------------------------------------------------------------------------------------------------------------------------------------------------- While SecondRoundButton = True If player1Button = True: t2.start()#mini timer player1LED = High time.sleep(.5) player1LED = Low time.sleep(.5) player1LED = High player1Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player1LED = Low If player2Button = True: t2.start()#mini timer player2LED = High time.sleep(.5) player2LED = Low time.sleep(.5) player2LED = High player2Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player2LED = Low If player4Button = True: t2.start()#mini timer player4LED = High time.sleep(.5) player4LED = Low time.sleep(.5) player4LED = High player4Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player4LED = Low ----------------------------------------------------------------------------------------------------------------------------------------------------- Else: player3LED = Low If player4Button = True: t2.start()#mini timer player4LED = High time.sleep(.5) player4LED = Low time.sleep(.5) player4LED = High player4Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. ----------------------------------------------------------------------------------------------------------------------------------------------------- While SecondRoundButton = True If player1Button = True: t2.start()#mini timer player1LED = High time.sleep(.5) player1LED = Low time.sleep(.5) player1LED = High player1Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player1LED = Low If player2Button = True: t2.start()#mini timer player2LED = High time.sleep(.5) player2LED = Low time.sleep(.5) player2LED = High player2Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player2LED = Low If player3Button = True: t2.start()#mini timer player3LED = High time.sleep(.5) player3LED = Low time.sleep(.5) player3LED = High player3Button.state(["disabled"]) # Disable the button. #if player is wrong, send the other 3 players to redemtion round. Else: player3LED = Low ----------------------------------------------------------------------------------------------------------------------------------------------------- Else: player4LED = Low
No comments:
Post a Comment