Traveling in Blanquillo AND MORE
  • Home
  • Trips
    • 2022 >
      • 2022 Tennessee
      • 2022 Blue Ridge Parkway
    • 2021
    • 2020 >
      • 2020 Sierras
    • 2019 >
      • 2019 Crater Lake
      • 2019 Westside Regional Park
    • 2018 >
      • 2018 So.California
      • 2018 Colorado-Arizona
      • 2018 Banff-Jasper
      • 2018 Osoyoos, BC
    • 2017 >
      • 2017 Olympic
      • 2017 Channel Islands
      • 2017 Eclipse
    • 2016 >
      • 2016 Glacier-Yellowstone
      • 2016 Southwest
    • 2015 >
      • 2015 Bryce-Zion
      • 2015 Lava Beds
      • 2015 Bristlecone-Yosemite
      • 2015 July first trip
    • 2014 >
      • 2014 Utah
    • 2011 >
      • Gold Beach
  • Camping Map
  • Our Escape
  • Radio and Hobbies
    • Amateur Radio Commentary >
      • AREDN
      • Antenna on mast
      • Winlink
    • Christmas LED Display
    • Scripts for Growing Classes >
      • 12- WeatherFIles
      • 11- sketch_MorseCodeDecoder.ino
      • 2e-RGB-LED
      • 2f-RGB-LED-GUI
      • 2g-RGB-LED-GUI
      • 3a-thermometer.py
      • 3b-thermometer-plus
      • 4a_DHT_simpletest.py
      • 4b_DHT_send_temperature.py
      • 4c_DHT_send_temperature_LED.py
      • 4c_DHT_send_temp.service
      • 4d_DHT_send_temp_LED_OLED.py
    • Winlink for Field Day 2020
    • VE Credentials
    • Antenna Analyzer Code
  • Collegedale Tax Prep
  • Links
  • Contact
  • Home
  • Trips
    • 2022 >
      • 2022 Tennessee
      • 2022 Blue Ridge Parkway
    • 2021
    • 2020 >
      • 2020 Sierras
    • 2019 >
      • 2019 Crater Lake
      • 2019 Westside Regional Park
    • 2018 >
      • 2018 So.California
      • 2018 Colorado-Arizona
      • 2018 Banff-Jasper
      • 2018 Osoyoos, BC
    • 2017 >
      • 2017 Olympic
      • 2017 Channel Islands
      • 2017 Eclipse
    • 2016 >
      • 2016 Glacier-Yellowstone
      • 2016 Southwest
    • 2015 >
      • 2015 Bryce-Zion
      • 2015 Lava Beds
      • 2015 Bristlecone-Yosemite
      • 2015 July first trip
    • 2014 >
      • 2014 Utah
    • 2011 >
      • Gold Beach
  • Camping Map
  • Our Escape
  • Radio and Hobbies
    • Amateur Radio Commentary >
      • AREDN
      • Antenna on mast
      • Winlink
    • Christmas LED Display
    • Scripts for Growing Classes >
      • 12- WeatherFIles
      • 11- sketch_MorseCodeDecoder.ino
      • 2e-RGB-LED
      • 2f-RGB-LED-GUI
      • 2g-RGB-LED-GUI
      • 3a-thermometer.py
      • 3b-thermometer-plus
      • 4a_DHT_simpletest.py
      • 4b_DHT_send_temperature.py
      • 4c_DHT_send_temperature_LED.py
      • 4c_DHT_send_temp.service
      • 4d_DHT_send_temp_LED_OLED.py
    • Winlink for Field Day 2020
    • VE Credentials
    • Antenna Analyzer Code
  • Collegedale Tax Prep
  • Links
  • Contact
​# 2g-RGB-LED-GUI.py
# 2020-06-20 revised for common anode configure option
# use GUI sliders to control LEDs
# to install guizero: $ pip3 install guizero
from guizero import App, Slider, Text
from gpiozero import PWMLED
#import time

# define methods to change LED brightness
def update_red(duty):
    red.value = (float(duty)/100)
    # change the led brightness to match the slider

def update_green(duty):
    green.value = (float(duty)/100)
    
def update_blue(duty):
    blue.value = (float(duty)/100)

# Configure the GPIO pins
red=PWMLED(24,False)    # False because common anode
green=PWMLED(23,False)
blue=PWMLED(18,False)

# Start Pulse Width Modulation (PWM) on the red, green and blue channels 
red.value = 0       # start at minimum brightness
green.value = 0
blue.value = 0

# create GUI and name it app
app = App(title='RGB LED Control', layout='grid')

# create labels for sliders and text
red_label = Text(app, text='Red', grid=[0,0])
green_label = Text(app, text='Green', grid=[0,1])
blue_label = Text(app, text='Blue', grid=[0,2])
stop_label = Text(app, text='use ther upper right X to stop script', grid=[0,3,2,1])

# create sliders
red_scale = Slider(app, grid=[1,0], command=update_red)
green_scale = Slider(app, grid=[1,1], command=update_green)
blue_scale = Slider(app, grid=[1,2], command=update_blue)

#size and position the GUI
app.tk.geometry("300x200+300+300")

# display the sliders and get values
try:
    app.display()
finally:  
    print("Cleaning up")
    red.value = 0       # turn off LED when exiting
    green.value = 0
    blue.value = 0
Copyright © 2023 by Dornbush Web Design