In this project, we have used Python GUI along with Raspberry Pi to control an LED. Pin number 8 on the Raspberry Pi has been configured as the output. The code for running this program consists of 2 functions – ON and OFF and 2 Buttons which are used to call these aforementioned functions.
Import all the necessary packages - tkinter, Rpi.GPIO, time. The package time has been imported in case the function time.sleep is required. However, it has not been used and therefore can be omitted.
Create a window using Tk() and specify its geometry and title.
Set up the GPIO pins and configure Pin number 8 as Output
Define 2 functions to turn the LED on and off
Create 2 buttons in the window and give them the previously mentioned functions as command.
Put the window in a loop.