how to control ultrasonic the servo should be steady if not detected by hands,upon closer your hand servo is get faster?

i need a code for ultasonic motor, controlling the servo motor. it should be steady if not detected by hand, and upon your hands getting closer to the ultrasonic the servo mototr getting faster. thank you

iceng1 month ago

Execute this unique simple algorithm..

As the echo return time is collected use that value directly in the motor OFF PWM timer...

Example ; Your hand is coming closer and the return time is shorter and the motor off time is shorter, which means the motor has more power, which makes the motor run faster !

Easy coding in any language Especially Assembly :-)

iceng iceng1 month ago

Yes you need to set some limits..

A limit when the return is from so far away that the audio signal is too weak to be heard by the transducer and the time is effectively OXO infinite = any off time greater then minimum RPM is set to minimum RPM..

Figure out what to do when a return arrives while the Chirp signal is still leaving is for you to solve, have fun !

rickharris1 month ago

More information:

Processor, Ultrasonic unit, Servo type.

This seems fairly simple can you not modify some existing code library?

check US time delay

Calculate distance

Is distance <> a set amount

IF less then move servo.

You will need PWM routines if you want to control the speed of a DC motor.