Skip to content

Instantly share code, notes, and snippets.

@IdrisCytron
Created July 1, 2019 03:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IdrisCytron/da62ca957e7c542333422bc7103bb063 to your computer and use it in GitHub Desktop.
Save IdrisCytron/da62ca957e7c542333422bc7103bb063 to your computer and use it in GitHub Desktop.
Controlling LED on Maker pHAT using simple Raspberry Pi GUI.
from guizero import App, Text, PushButton, CheckBox
from gpiozero import LED
app = App(title="Maker pHAT LED", width=380, height=280, layout="grid")
led1 = LED(17)
led2 = LED(18)
led3 = LED(27)
led4 = LED(22)
led5 = LED(25)
led6 = LED(12)
led7 = LED(13)
led8 = LED(19)
def ActivateLED():
led1.value = CheckBoxLed1.value
led2.value = CheckBoxLed2.value
led3.value = CheckBoxLed3.value
led4.value = CheckBoxLed4.value
led5.value = CheckBoxLed5.value
led6.value = CheckBoxLed6.value
led7.value = CheckBoxLed7.value
led8.value = CheckBoxLed8.value
welcome_message = Text(app, text="Choose which LED to light up?", grid=[0,0], align="left")
CheckBoxLed1 = CheckBox(app, text="LED1", grid=[0,1], align="left")
CheckBoxLed2 = CheckBox(app, text="LED2", grid=[0,2], align="left")
CheckBoxLed3 = CheckBox(app, text="LED3", grid=[0,3], align="left")
CheckBoxLed4 = CheckBox(app, text="LED4", grid=[0,4], align="left")
CheckBoxLed5 = CheckBox(app, text="LED5", grid=[0,5], align="left")
CheckBoxLed6 = CheckBox(app, text="LED6", grid=[0,6], align="left")
CheckBoxLed7 = CheckBox(app, text="LED7", grid=[0,7], align="left")
CheckBoxLed8 = CheckBox(app, text="LED8", grid=[0,8], align="left")
activate_led = PushButton(app, command=ActivateLED, text="Activate LED", grid=[0,9], align="left")
thank_you = Text(app, text="Thank you. By Idris.", grid=[1,10], align="right")
app.display()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment