How to configure Hcsr 04 rangefinder?

I am making a copter using ardupilot pixhawk 2.4.8, I am having problems in land mode because my barometer is not very stable, so I thought of adding a rangefinder, so I bought a hcsr 04, but when I connected it to pixhawk, I realized that I could not get output, since the BRD_PWM_COUNT parameter changed after ardupilot 4.2, I could not find a satisfactory source on the internet about this subject, I am using ardupilot 4.5.
good forums

https://ardupilot.org/copter/docs/common-rangefinder-hcsr04.html

Note

in firmware versions 4.2 and later, the method for setting a PWM/SERVO/MOTOR output to be a GPIO function is changed. Instead of BRD_PWM_COUNT being used, the individual SERVOx_FUNCTION parameter is merely set to “-1”. If set to “0”, it remains a PWM output, unassigned to a function, and outputs that output’s trim value when board safety is not active. If the servo function is being “mirrored” to a remote device, as in the case of a DroneCAN or KDECAN ESC, then in order to change the autopilot board’s corresponding output pin to be a GPIO, but allow the SERVOx_FUNCTION to still be assigned to the remote device, the SERVO_GPIO_MASK parameter can be used to assign the board pin to be a GPIO without affecting the SERVOx_FUNCTION assignment for the remote device.

1 Like

solved the problem

It worked after replacing hcsr-04