Object Avoidance with the Ultrasonic Ping Sensor
lobo
Posts: 100
Let me first set the scene:
I·build a mobilebot that has the following features:
This is basically my setup as of know. I will add later.
I'am not to good at Pbasic.Although I am a novice C++ programmer.
I dont want to use the roaming with ping right know. I find it to crowded.
I need something simple, such as:
If (Blank > 12) Then
PULSOUT aHB25, 650
PULSOUT bHB25, 650
PULSOUT cHB25, 750
PULSOUT dHB25, 750
But how do i get the info from the Ultrasonic Sensor· to make this program work.
Blank would have to be the name of the function or name of the variable that gets this done right?
I need something simple. I'm not asking nobody to write me a complete program--no no. I just need the command or short·formula to get the info from the sensor and put that in the IF (Blank > 12) .
Bottom line how is it done. Just a simple little formula.
I·build a mobilebot that has the following features:
- 4 hb25 motor controllers
- 4 motors with gears (they were taken out of those jeep electric toys that Walmart sales. My kids rode on them so they can handle up to 80-90 pounds)
- 12 volts at 9.5 Amps an hour
- 4 Vex bumpers or switches(2 bumpers and 2 switches).
- 2 Ping Ultrasonic Sensor
This is basically my setup as of know. I will add later.
I'am not to good at Pbasic.Although I am a novice C++ programmer.
I dont want to use the roaming with ping right know. I find it to crowded.
I need something simple, such as:
If (Blank > 12) Then
PULSOUT aHB25, 650
PULSOUT bHB25, 650
PULSOUT cHB25, 750
PULSOUT dHB25, 750
But how do i get the info from the Ultrasonic Sensor· to make this program work.
Blank would have to be the name of the function or name of the variable that gets this done right?
I need something simple. I'm not asking nobody to write me a complete program--no no. I just need the command or short·formula to get the info from the sensor and put that in the IF (Blank > 12) .
Bottom line how is it done. Just a simple little formula.
Comments
It's from the PING product page. It shows you how to trigger the PING and get a number back from it (time to echo). The PING documentation (linked from the same product page) shows you how to convert this to centimeters or inches or whatever units you want which you could use in your IF statement. You will need to do this measurement periodically.
Right in the code for the PING))) Demo is the key to what you need to do…Stuff the code to read the PING))) and set the inches/cm variables and you’re set. When it returns you can do conditionals based on the values returned.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support