'Ui' was not declared in this scope

You really should check the return type of ping_cm - 255xm.isnt that far, and a sensor could return a valid, bigger value.
And you really should ping just once, and store the result.

1 Like