Create A Simple GUI On Raspberry Pi To Control LEDs

Measure your water usage using water flow sensor.


When we talk about GUI (Graphical User Interface), normally we will develop using our laptop/PC and using popular software like Microsoft Visual StudioProcessing, Eclipse or etc. Since Raspberry Pi is a computer, why not we try to develop GUI on that? And we use Python, the most popular programming language.


This video will show you how to create a simple GUI on Raspberry Pi to control LEDs on Maker pHAT.

Hardware Preparation

This is the list of items used in the video.

Sample Program

This is the sample code to create a simple 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")

Thank You


  1. Raspberry Pi: Getting started with GUIs
  2. GUI library package – guizero

Thanks for reading this tutorial. If you have any technical inquiry, please post at Cytron Technical Forum.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

Is it possible to program Maker UNO with Python?
Camera and DSI Driver on the Latest Raspberry Pi Bullseye OS
Remote Control ZOOM:BIT using Grove 8266 WiFi and Blynk
Icon Case with Heatsinks & Fan Stressberry Test
Low Profile Aluminum Case Stressberry Test
Tutorials of Cytron Technologies Scroll to Top