Pages: [1]   Go Down
Author Topic: 4 ping and a servo  (Read 397 times)
0 Members and 1 Guest are viewing this topic.
United States
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,

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! smiley




http://www.flickr.com/photos/mwsmith/?uploaded=1&magic_cookie=e8e51f7b40aa84bcf8af095623602ef0


* ping and servo.jpg (152.79 KB, 2004x1504 - viewed 6 times.)
Logged

Toledo, OH
Offline Offline
God Member
*****
Karma: 36
Posts: 510
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everyone,

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! smiley

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.

Tim
Logged

Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

United States
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the reply. I will look at the provided links and see what steps I can take. I'll post my results.
Logged

Pages: [1]   Go Up
Jump to: