Arduino ultrasonic sensor activating servo movement?

I am building a rc car as part of a pretty big project that has a bunch of other stuff on it . But one thing I can't figure out, being I'm only slightly familiar with arduino (UNO), is how to make a servo move when the sensor tells it to. I am going to attach a hook on the front to lift up an object so I can transport it. Now what I want to do is have the sensor detect the object when it is close enough to the hook (3-4") and then tell the servo to move a given degrees, around 25, just enough to pick it up. I've been toying with the code for the obstacle detecting robots trying to see if I cant modify that for this type of use but a lot of that code is backup commands, alternate routes and all that other stuff. just need a simple detect object, send signal to servo and servo moves the hook to pick the object up. Thanks  

Need to take readings from the sensor. See what readings you get when objects pass in the range that you want. Record those reading and you'll have a range to work with. Now when the arduino sees a reading between the bottom and top range of the readings it can activate the servo for you.

dmegill (author)  mpilchfamily3 years ago
Yeah I'm not that deep into it yet to know. I managed to make it put accurate distance readings into the debug but that's it. Could you explain a little bit more so I can figure it out?