HC-SR04 -> Pixhawk Adaptor using an Arduino Nano
Arduino Nano sketch to integrate the HC-SR04 sonar module with the Pixhawk flight control board.
The Arduino outputs a PWM signal representing distance (5v peak).
The Pixhawk expects to see an analog voltage (MAX 3.3v on ADC IN), the Nano analog output pins are not true analog, they are PWM.
A conversion circuit is required to both step down the voltage and convert signal to near analog DC signal. (A voltage divider and low pass filter)
The most challenging requirement is most likely sourcing the 5 pin DF13 connector that is needed on the pixhawk.
Further comments and instructions are provided in the source header.