Society of Robots - Robot Forum

Software => Software => Topic started by: AdvsNoob on April 29, 2009, 09:42:33 PM

Title: Ultra Sonic Range Finder "Good Tutorial"
Post by: AdvsNoob on April 29, 2009, 09:42:33 PM
Hay im new in working with this type of sensor.. Is there a good tutorial that will show me how to make something happedn like lets say run another command to search with the servo to turn it left and right...

If you where able to under stand that...

Simple explanation

When i get lets say 4 in's to a wall, It will Goto another script to move a servo left 90 degrees and right 90 degrees

Sorry for bad English!
Title: Re: Ultra Sonic Range Finder "Good Tutorial"
Post by: hazzer123 on May 02, 2009, 04:33:27 AM
If you are already able to get readings from the sensor then the rest is just programming. Something like this would be easy.

Code: [Select]
while(1) {
  if(sensor_reading > 4inches) {
    go_forward();
  } else {
    servo_routine();
  }
}

There are other ways of doing it... Maybe you could set an interrupt on the event of a comparator toggle (if the sensor can give an analogue voltage output). Or you could have a timer interrupting the code for a regular check of the sensor readings. These methods would allow your robot to do other things at the same time (with ease).
Title: Re: Ultra Sonic Range Finder "Good Tutorial"
Post by: AdvsNoob on May 02, 2009, 06:33:03 PM
ya we got it set up using less than and equal to, its working nicely but the thing that sucks is he lives 20 mins away but we got far!

Here is the robots page

http://www.societyofrobots.com/member_tutorials/node/224 (http://www.societyofrobots.com/member_tutorials/node/224)