Adding Multinple PING Ultra sound sensor... please help!!!!
Hi all!
So I have recently started using microcontrollers for class with fellow classmate thetarbe,
My problem is this. I have gotten then code for the PING Ultrasound sensor and it works fine. I just want to add another PING Ultrasound sensor to have two. How would i modify the syntax?
Here is a copy of the current syntax.... thanks!
' Smart Sensors and Applications - PingMeasureCmAndIn.bs2
' Measure distance with Ping))) sensor and display in both in & cm
' {$STAMP BS2}
' {$PBASIC 2.5}
' Conversion constants for room temperature measurements.
CmConstant CON 2260
InConstant CON 890
cmDistance VAR Word
inDistance VAR Word
time VAR Word
DO
PULSOUT 15, 5
PULSIN 15, 1, time
cmDistance = cmConstant ** time
inDistance = inConstant ** time
DEBUG HOME, DEC3 cmDistance, " cm"
DEBUG CR, DEC3 inDistance, " in"
PAUSE 100
LOOP
So I have recently started using microcontrollers for class with fellow classmate thetarbe,
My problem is this. I have gotten then code for the PING Ultrasound sensor and it works fine. I just want to add another PING Ultrasound sensor to have two. How would i modify the syntax?
Here is a copy of the current syntax.... thanks!
' Smart Sensors and Applications - PingMeasureCmAndIn.bs2
' Measure distance with Ping))) sensor and display in both in & cm
' {$STAMP BS2}
' {$PBASIC 2.5}
' Conversion constants for room temperature measurements.
CmConstant CON 2260
InConstant CON 890
cmDistance VAR Word
inDistance VAR Word
time VAR Word
DO
PULSOUT 15, 5
PULSIN 15, 1, time
cmDistance = cmConstant ** time
inDistance = inConstant ** time
DEBUG HOME, DEC3 cmDistance, " cm"
DEBUG CR, DEC3 inDistance, " in"
PAUSE 100
LOOP
Comments
All you need is a 2nd PULSOUT and PULSIN with the proper pin number. If you need to keep the 2nd set of measurements around, you will need another set of variables with different names. Try it. You might want to put a little delay between the two PING measurements to allow echos in the room to die out. 50-100ms would be more than enough.
' Smart Sensors and Applications - PingMeasureCmAndIn.bs2
' Measure distance with Ping))) sensor and display in both in & cm
' {$STAMP BS2}
' {$PBASIC 2.5}
' Conversion constants for room temperature measurements.
CmConstant CON 2260
InConstant CON 890
cmDistance VAR Word
inDistance VAR Word
time VAR Word
DO
PULSOUT 15, 5
PULSIN 15, 1, time
PAUSE 500
PULSOUT 14, 5
PULSIN 14, 1, time
cmDistance = cmConstant ** time
inDistance = inConstant ** time
DEBUG HOME, DEC3 cmDistance, " cm"
DEBUG CR, DEC3 inDistance, " in"
PAUSE 100
LOOP
got both sensors to diplay on-screen....
next step : To put both sensor display results on a small LCD screen
any advice?!?!?
Good luck!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"A complex design is the sign of an inferior designer." - Jamie Hyneman, Myth Buster
DGSwaner
thanks..
By the way, it's against forum rules to post multiple messages on the same subject. Please delete your other message. Use the X icon in the upper right corner of the message box.