[Tutor] Thread Object integration with GPIO
Marc Eymard
marc_eymard at hotmail.com
Sat Apr 29 14:26:28 EDT 2017
Hello there,
I have hooked up an ultrasonic sensor to my Raspberry Pi-enabled robot
in order to get continuous distance-to-obstacle reading.
The sensor is properly connected via GPIO and already reads the distance
properly when running a simple script.
However, I need to integrate the sensor reading logic to an existing
script provided by PiBorg called YetiBorg.py
The way I have decided to go about implementing the sensor reading is by
creating a Thread object and update the distance attribute of this very
same object from the run() function. The idea is to encapsulate the
distance reading within the sensor object as much as possible by i.
creating a sensor/thread object and by ii. avoiding global variables.
Attached the script I have come up with, which keeps returning multiple
run time errors whenever I try to fix it.
I believe there are multiple issues, but at least it gives an idea of
what I currently want to achieve and how.
Can a charitable soul advise whether my approach makes sense and whether
I am using the right type of object for the task at hands?
I am looking for guidance and willing try completely different
approach/objects if necessary.
Thanks in advance for sending me into the right direction.
Marc
More information about the Tutor
mailing list