Home / How To / Read Ultrasonic Sensor (HC-SR04) Data on a 128 × 128 LCD and visualize them with Matplotlib: 8 steps

Read Ultrasonic Sensor (HC-SR04) Data on a 128 × 128 LCD and visualize them with Matplotlib: 8 steps



You can use any Python IDE, in this case I use PyCharm. Before you begin, make sure that the following conditions are met:

-> You have installed Python. You can download it from: https://www.python.org/downloads/ebrit19659003achte-> Chapter19459005] You work with the PyCharm Community.

In. Creating a Python script in PyCharm

S1. Let's start our project: if you are on the Welcome screen, click Create New Project. If you have already opened a project, choose File -> New Project.
S2. Select pure Python -> Location (specify directory) -> Project Interpreter: New Virtualenv Environment -> Virtualenv Tools -> Create.
S3. In the Project Tools window, select the project root and then select File -> New -> Python file -> Type the new file name.
S4. PyCharm creates a new Python file and opens it for editing.

II. Install the following packages: PySerial, Numpy and Matplotlib.

S1

. Matplotlib is a plot library for Python.
S2. NumPy is the basic package for scientific data processing in Python.
S3. PySerial is a Python library that supports serial connections across a variety of devices.

III. To install optional package in PyCharm

S1. File -> Settings.
S2. Under Project, select Project Interpreter and click the “+” icon.
S3. Enter the package you want to install in the search field and click Install Package.


Source link