Book Image

Python Programming for Arduino

Book Image

Python Programming for Arduino

Overview of this book

Table of Contents (18 chapters)
Python Programming for Arduino
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Label() widget – monitoring I/O pins


Arduino projects often deal with real-time systems and are required to continuously monitor input values from digital and analog pins. Therefore, if these values are being displayed on a graphical interface, they need to be updated periodically or when the state of a pin changes.

If you observe the previous GUI exercises, you will notice that we initialized the root window using mainloop() at the end of the code, which started the Tkinter loop and initialized all the widgets with the updated values. Once the mainloop() was initialized, we did not use any other Tkinter class or method to periodically update the widgets with the latest values.

In this exercise, we will use a potentiometer to provide variable input to the analog pin 0, which will be reflected by Tkinter's Label() widget. To update the label and display the values of the analog input, we are going to implement a few Python and Tkinter tricks. As we are using a potentiometer to provide input...