The Scale() widget – adjusting the brightness of an LED

In this section, we will develop some code to change an LED's brightness using the Python GUI. Previously, we learned that you can use a digital pin of Arduino to produce an analog output using PWM. Although you can use the Entry() widget to provide one time value for the PWM signal, it will be useful to have a widget that can dynamically provide this value. As brightness can be fluctuated between 0 and 100 percent, it makes sense to use a slider that varies between 0 and 100. The Tkinter library provides this kind of sliding interface using the Scale() widget.

As we are working to change the brightness of the LED and supply analog input, we will be using a digital pin with the PWM support. ...

Get Python Programming for Arduino now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.