# Importing Libraries import RPi.GPIO as GPIO import time from tkinter import * import tkinter.font from gpiozero import CPUTemperature # Libraries Imported successfully # Raspberry Pi 3 Pin Settings LED = 12 # pin12 GPIO.setwarnings(False) GPIO.setmode(GPIO.BOARD) # We are accessing GPIOs according to their physical location GPIO.setup(LED, GPIO.OUT) # We have set our LED pin mode to output GPIO.output(LED, GPIO.LOW) # When it will start then LED will be OFF cpu = CPUTemperature() PwmValue = GPIO.PWM(LED, 50) PwmValue.start(0) # Raspberry Pi 3 Pin Settings # tkinter GUI basic settings Gui = Tk() Gui.title("GUI in Raspberry Pi 3") Gui.config(background= "#0080FF") Gui.minsize(200,200) Font1 = tkinter.font.Font(family = 'Helvetica', size = 24, weight = 'bold') # tkinter simple GUI created def ledON(): GPIO.output(LED, GPIO.HIGH) # led on #Text2 = Label(Gui,text=' ON ', font = Font1, bg = '#0080FF', fg='green', padx = 0) #Text2.grid(row=0,column=1) def ledOFF(): GPIO.output(LED, GPIO.LOW) # led off #Text2 = Label(Gui,text='OFF', font = Font1, bg = '#0080FF', fg='red', padx = 0) #Text2.grid(row=0,column=1) def ChangePWM(self): PwmValue.ChangeDutyCycle(Scale1.get()) def ChangeFREQ(self): PwmValue.ChangeFrequency(Scale2.get()) #Text1 = Label(Gui,text='LED Status:', font = Font1, fg='#FFFFFF', bg = '#0080FF', padx = 50, pady = 50) #Text1.grid(row=0,column=0) #Text2 = Label(Gui,text='OFF', font = Font1, fg='#FFFFFF', bg = '#0080FF', padx = 0) #Text2.grid(row=0,column=1) #Button1 = Button(Gui, text=' LED ON', font = Font1, command = ledON, bg='bisque2', height = 1, width = 10) #Button1.grid(row=1,column=0) #Button2 = Button(Gui, text=' LED OFF', font = Font1, command = ledOFF, bg='bisque2', height = 1, width = 10) #Button2.grid(row=1,column=1) Text1 = Label(Gui,text=cpu.temperature, font = Font1, fg='#FFFFFF', bg = '#0080FF', padx = 50, pady = 50) Text1.grid(row=0,column=0) Scale1 = Scale(Gui, from_=0, to=100, orient = HORIZONTAL, resolution = 1, command = ChangePWM) Scale1.grid(row=1,column=0) Scale2 = Scale(Gui, from_=1, to=50, orient = HORIZONTAL, resolution = 0.5, command = ChangeFREQ) Scale2.grid(row=1,column=2) #Text3 = Label(Gui,text='www.TheEngineeringProjects.com', font = Font1, bg = '#0080FF', fg='#FFFFFF', padx = 50, pady = 50) #Text3.grid(row=2,columnspan=2) Gui.mainloop()