Replacing a tactile switch with an ultrasonic ranger
A simple comparator circuit will do:







simulate this circuit &ndash; Schematic created using CircuitLab

U1 can be a slow, rail-to-rail CMOS part that costs under $1 - either a general purpose op-amp, or a dedicated comparator. Ensure that there's no diode between (+) and (-) inputs. Microchip has plenty of them, for example.

Since we assume push-pull outputs like on every op-amp, there's no need for any pull-up/pull-down resistors on the output of U1. If you use an op-amp, that'll be the case. With comparators - it varies.

The ratio of R3 to R4 sets the amount of hysteresis - here it's at 1%. The turn-on voltage is set by the ratio of R1 to R2, and given by VCC * R1/(R1+R2) * (1 - R3/R4). R5 isolates the gate capacitance from the amplifier's output, preventing the amplifier from oscillating.