Help write code

greetings I am trying to program my servo to stop or delay when my ultrasonic sensor picks up anything less than 10 cm

my ultrasonic is on a sweep

Why did you start a topic in the Uncategorised category of the forum when its description is

:warning: DO NOT CREATE TOPICS IN THIS CATEGORY :warning:

Your topic has been moved to the Programming category

Post your sketch that you have tried.

When the ultrasonic distance is greater than 10 cm, the servo starts moving from 0 to 180 first and then continues towards 180 to 0. if the value is less than or equal to 10cm, it stops after completing the movement. and the ultrasonic reading updates itself every second. and delays the servo movement by 0.1 second.

Show us what we're working with here please.
Run the sonar range test module and see if you can get a reading from it.
You'll need to use a hard reflector facing head on for test. The sound beam is very directional and is absorbed by soft materials.

You mean a pivot or rotating platform?

If your servo is not moving, make sure to point your ultrasonic sensor UP (a little) so it is not sensing the surface.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.