TCSS573: loT Quiz 1 Part 3 Smart Home Dashboard v 2.0 79 Main Bedroom Turn OFF Basement Office Turn ON Living Room Turn OFF Exit 75 176 X
How can you extend the above functionality using two additional LED modules and attaching them to the GUI where you can control the light intensity (e.g. fading) and ON/OFF operations for each LED.
the one i managed to configure is myLED5. I would to achieve an output like this from the code
code
from guizero import App,Box,Text,PushButton,Slider
from grovepi import *
import time
myLED3 = 3 #blue
myLED5 = 5 #red
myLED6 = 6 #green
pinMode(myLED3,0)
pinMode(myLED5,0)
pinMode(myLED6,0)
def exitProgram():
digitalWrite(myLED3,0)
digitalWrite(myLED5,0)
digitalWrite(myLED6,0)
app.destroy()
def SliderToggleLED5(slider_value):
analogWrite(myLED5, int(slider_value))
def led1Toggle():
button_status = digitalRead(myLED5)
if (button_status == 0):
digitalWrite(myLED5,1)
ledButton1.text ="Turn off"
ledButton1.bg ="green"
ledButton1.text_color="white"
textLED5.color ="green"
else:
digitalWrite(myLED5,0)
ledButton1.text ="Turn off"
ledButton1.bg ="red"
ledButton1.color="black"
app = App(title="TCSS573: IOT Quiz Part 3", height =300, width = 500)
main =Text(app, text ="Smart Home Dashboard Ver 1.0", size=14, font="Time New Roman", color="navy")
box = Box(app, layout ="grid", grid =[1,0])
textLED5 = Text(box, text="Main Bedroom", align ="left", grid =[0,0])
ledButton1 =PushButton(box, command=led1Toggle, text="Turn ON", grid=[1,0])
sliderLED5=Slider(box, start=0, end =255, command = SliderToggleLED5, grid=[4,0])
exitButton = PushButton(box, command=exitProgram , text="Exit", grid=[2,8])
app.display()
Step by step
Solved in 2 steps