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

Plotting real-time Arduino data


In the previous chapter, while dealing with GUI and Arduino data, you must have noticed that the code was updating the interface with every new value that was obtained from the Arduino sensors. Similarly, in this exercise, we will be redrawing the plot every time we receive new values from Arduino. Basically, we will be plotting and updating a real-time chart instead of plotting the entire set of sensor values as we did in the previous exercise.

We will be using the same Arduino circuit that you built in the previous exercises. Here, we will utilize only the potentiometer section of the circuit to obtain the analog sensor values. Now, before we explain the new methods used in this exercise, let's first open the program file for this exercise. You can find the program file from this chapter's folder; it is named plotLive.py. In the code, change the appropriate parameters for the Arduino board and execute the code. While the code is running, rotate the knob of...