"""
filename:gpio_RPi_quiz_lighting.py
Further Project - Quiz - Lighting code
written by Trevor Olsson
© GPIO Support Services LTD MMXVII
More info here: https://www.gpio.co.uk/quiz
and here: https://gpiozero.readthedocs.io/en/stable/api_boards.html
"""
from gpiozero import LEDBoard, Button
from time import sleep
BtnA1 = Button(4,pull_up=False)
BtnA2 = Button(14,pull_up=False)
BtnA3 = Button(15,pull_up=False)
BtnA4 = Button(25,pull_up=False)
TeamALights = LEDBoard(17,18,27,22)
TeamBLights = LEDBoard(23,24)
AllLights = LEDBoard(TeamALights,TeamBLights)
while True:
Current_team=0 #This is Current Team flag; 1 is Team A answering, 2 is Team B, 0 is Starter Question - on live system this value is acquired from 'Scoring' code
if Current_team==0:
AllLights.on()
if BtnA1.is_pressed:
TeamALights.value = (1,0,0,0)
TeamBLights.off()
sleep(1)
if BtnA2.is_pressed:
TeamALights.value = (0,1,0,0)
TeamBLights.off()
sleep(1)
if BtnA3.is_pressed:
TeamALights.value = (0,0,1,0)
TeamBLights.off()
sleep(1)
if BtnA4.is_pressed:
TeamALights.value = (0,0,0,1)
TeamBLights.off()
sleep(1)
elif Current_team==1:
TeamALights.on()
TeamBLights.off()
sleep(1)
elif Current_team==2:
TeamBLights.on()
TeamALights.off()
sleep(1)
Comments