I read data from IR distance sensor from an Arduino that is connected to RPi. I see the data in the RPi.
I would like to control a servo motor connected to the Arduino from the RPi. For this task I have a separate thread that writes to the serial port.
The problem is that I'm constantly reading the input data from one thread that is responsible for reading and I'm not sure how to give the control to the thread that is responsible for writing, then when the second thread is done, to give control to the first.
Can someone give an example?