Script for ultrasonic sensor HC - SR04

I’ve designed a hexapod and am considering using a Maestro controller. My problem is I have an HC-SR04 ultrasonic sensor for obstacle avoidance and I’ve not been able to find a Maestro script for driving it. I have an Arduino UNO that I could use and then feed the output to the Maestro but I’d like to simplify the build and use the Maestro only.

Help on writing a script or an example would be greatly appreciated. Thanks.


The Maestro’s scripting language is very limited and not designed for accurately measuring pulse widths, so I do not think it would be suitable for that sensor. You might try reading the inputs with your Arduino Uno and then sending signals to the Maestro.


Thanks. I guess that will have to do.

strictly speaking you cannot use a HC-SR04 because for being able to use the full accuracy you would need a timer with 10us resolution and 50 ms max Duration which is not available on the Maestros.

But for practical purposes one resisor and one capacitor plus a script will do the trick.


I’ve documented it.
In case the links are not permanent, search “Share Your Projects” for HC-SR04 and Mini Maestros.