Hi.
I need to control servo motor in proportion with the distance my ultrasonic sensor detects.
I tried to remix the code that involves potentiometer, but it won't work with the sensors.
Also, I need to set a range on the distance.
It would be really helpful on my project if you can give me example codes.
Thanks!
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
If you have some code that uses an ultrasonic sensor to provide a distance value then that's a good start.
And you say you have code that moves a sensor according to the value obtained from a potentiometer.
You're almost there. So show us your attempt to take the value from the sensor and replace the potentiometer value with it to drive the servo. If it doesn't quite work we can help you sort it out.