-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode
More file actions
61 lines (44 loc) · 1.41 KB
/
code
File metadata and controls
61 lines (44 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from tkinter import *
import tkinter.font
from gpiozero import PWMLED
import RPi.GPIO
import math
RPi.GPIO.setmode(RPi.GPIO.BCM)
## GPIO pin declarations/Initialize PWM LED ##
ledBlue = PWMLED(14)
ledRed = PWMLED(23)
ledGreen = PWMLED(25)
## GUI DEFINITION ##
win = Tk()
win.title("LED Intensity Toggler")
myFont = tkinter.font.Font(family = 'Helvetica', size = 12, weight = "bold")
### EVENT FUNCTIONS ###
#BLUE SLIDER#
def updateBlue(value):
blueCycle = math.sqrt(float(value) / 100)
ledBlue.value = blueCycle
#RED SLIDER#
def updateRed(value):
redCycle = math.sqrt(float(value) / 100)
ledRed.value = redCycle
#GREEN SLIDER#
def updateGreen(value):
greenCycle = math.sqrt(float(value) / 100)
ledGreen.value = greenCycle
def exitToggle():
RPi.GPIO.cleanup()
win.destroy()
### WIDGETS ###
#BLUE WIDGET#
ledBlueSlider = Scale(win, from_ = 0, to = 100, orient = HORIZONTAL, command = updateBlue)
ledBlueSlider.grid(row = 0, column = 1)
#RED WIDGET#
ledRedSlider = Scale(win, from_ = 0, to = 100, orient = HORIZONTAL, command = updateRed)
ledRedSlider.grid(row = 1, column = 1)
#GREEN WIDGET#
ledGreenSlider = Scale(win, from_ = 0, to = 100, orient = HORIZONTAL, command = updateGreen)
ledGreenSlider.grid(row = 2, column = 1)
## EXIT BUTTON ##
exitButton = Button(win, text = 'EXIT', font = myFont, command = exitToggle, bg = 'bisque2', height = 1, width = 24)
exitButton.grid(row = 3, column = 1)
win.mainloop()