• Interactivity
  • PD and microsecond timing, or: how to connect a range finder

We are looking to interface an ultrasonic rangefinder with the Bela/PD for some projects in a class we are running and I've hit a few roadblocks. The sensor we are using is:
https://www.sparkfun.com/products/13959

It relies on microsecond timing of pulses in order to do the range-finding and while I know the Bela is capable of this PD does not appear to be. What we'd like to do, if possible, is create a program that will run in C++ and read the sensor data. Then it would pass values into the PD program that would be running the synthesis side of things. Not sure if this is possible or not. The alternative would be to just use an Arduino to read the sensor and pass values into the analog input of the Bela. Apologies if others have looked into similar topics, I couldn't turn anything up in a search.

Hello!
There is an example here which shows how to use that very sensor with Bela in C++.
I am not sure what the best way of doing it with PureData on Bela is. It may be compiling an external or using a customRender with libpd/heavy. The custom render.cpp would then perform the measurement (similar to the example above) and send the read values to the running PureData patch.

Also note that with this method the resolution of the measured pulse will be limited to 1/44100 s = 22.7us.