Determining Oncoming Object Has Stopped
I have a Basic Stamp II and have·a Ping Ultrasonic range finder on order.· I have a project where I want to monitor the decreasing distance to an oncoming object and fire a solenoid valve when the object "stops" (at least when the distance change is minimal).· I am new to programming but assume I can have the Stamp continue comparing·distance values from the Ping until the difference is virtually zero.· Once this condition occurs, an output signal can be sent to fire the solenoid.·
Is this a workable application for my Stamp and Ping?· If so, is there a reference code I can access and adapt?
Thanks in advance for any help.
Is this a workable application for my Stamp and Ping?· If so, is there a reference code I can access and adapt?
Thanks in advance for any help.

Comments
If you haven't done so already, take a look at the ping sample code on it's product page, and the books "What's a Microcontroller" and "Basic Stamp Syntax and Reference Manual" available as PDFs from Parallax.
' {$STAMP BS2} ' BASIC Stamp 2 ' {$PBASIC 2.5} ping PIN 15 ' Ping))) I/O pinping threshold CON 45 ' threshold value ticks VAR Word ' current distance measurement ticksOld VAR Word ' previous distance measurement PULSOUT ping, 5 ' Initialize previous distance PULSIN ping, 1, ticksOld DO ' Main loop PULSOUT ping, 5 ' Get current distance PULSIN ping, 1, ticks ' If difference in distances is below threshold then... IF ABS(ticks - ticksOld) <= threshold THEN DEBUG HOME, "slow enough" ELSE ' Otherwise... DEBUG HOME, "too fast " ENDIF ticksOld = ticks ' Save current as previouis PAUSE 50 ' Wait fixed amount of time LOOP ' repeat main loopFor more fun with the Ping))) sensor, download Smart Sensors and Applications from www.parallax.com -> Downloads -> Stamps in Class·Downloads.· See Chapter 2.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
According to their newsletter, I believe it's "Parallaxians"... [noparse]:)[/noparse]