I'm stuck on trying to hash out code for a project i'm working on. I basically want to 4 ping sensors to measure out distance. Which ever sensor has the shortest distance (someone walking in front of it) the continuous servo would turn to that position. It may be crude but it is to my level as understanding code. I have worked with servos and ping sensors before but this would be the next step. I don't want to use any cameras as I want this to be as small as possible so no laptop is a plus. I have always been able to work through found code and modify as need in the past but am at a road block with this. I figured it would be best to reach out and start fresh code wise. Does anyone know of existing code that I may be lead to or is willing to take the time to write something? I can understand existing code but am not able to fully write from a blank slate. I have attacked an image to help visualize my project. I would assume it would just be a series of if statements but feel free to correct me!
The NewPing library will easily allow integration of multiple ultrasonic sensors.http://arduino.cc/forum/index.php/topic,106043.0.html
Sample sketch that interfaces with 15 sensors can be found here:http://code.google.com/p/arduino-new-ping/wiki/15_Sensors_Example
For your project, you would first adjust the sketch for your 4 sensors (instructions are in the sketch on how to do this). Then, in the oneSensorCycle function you would figure out what sensor had the lowest value (but not zero) and then you would do whatever servo code you needed to move the servo in the direction of the selected sensor.