"multiple Values in one PIN port" doesn't make sense the way you've said it. Can you give a bit more explanation of what you're trying to do?
There are plenty of examples on the Parallax website of how to use the PING))) with a Stamp. Have you looked at them? Like most Parallax products, there are links to the documentation and sample code on the product page in the webstore.
Mike Green said...
"multiple Values in one PIN port" doesn't make sense the way you've said it. Can you give a bit more explanation of what you're trying to do?
There are plenty of examples on the Parallax website of how to use the PING))) with a Stamp. Have you looked at them? Like most Parallax products, there are links to the documentation and sample code on the product page in the webstore.
I'm trying to Get the Ping to do a distance measure at 5 angles. And store then compare the values.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BWIN ON DA POWAH WIFIN U!!!
The PING))) can't store or compare values. Your Stamp program has to do that. The documentation for the PING))) shows how to make a single measurement. The Stamp Manual shows how to declare arrays. You'd use an array to store each of the distance measurements, then your program can go back and analyze the stored values.
If you really MUST store all 5 measurments you should use an array like mike said, BUT, if you merely want to store the largest value(to take bot the furthest distance) and at what angle that measurment was found , I used a loop to take the 5 measurements and use 1 variable to hold the biggest one. Following is a copy from my code:
FOR X = 787 TO 2650 STEP 465 ' these values are for the bs2p, bs2 would be different
C = C + 1
FOR XY = 1 TO 35
PULSOUT 14, X
PAUSE 20
NEXT
PULSOUT 15, 13
PULSIN 15, 1, TIME
TIME = TIME */ 102 ' FOR BS2P, NOT BS2
inches = 890 ** time : time = 0
IF (inches > BIG) THEN ' THIS IS WHERE COMPARISON IS MADE
BIG = inches
XBIG = C
ENDIF
NEXT
C = 0 ' C MUST BE RESET BEFORE ENTERING BACK IN PREVIOUS LOOP
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ "THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
How would you change the code slightly to find the shortest distance instead? that way you could know the furtherest and the closest. Hope you don't mind me asking.
No problem MovieMaker. Just simply add another -If then- block after the one that finds the biggest distance. Just do the inverse of it and use a seperate variable to hold the lowest.:
IF (inches < LOW) THEN ' THIS IS WHERE COMPARISON IS MADE
LOW = inches
XLOW = C ' XLOW holds at what measurement position( 1- 5) that was taken
ENDIF
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ "THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
Bear in mind that the shortest of five distance measurements could well be erroneous, due to interference. The longest of five measurements is much more likely to be an accurate value.
Comments
There are plenty of examples on the Parallax website of how to use the PING))) with a Stamp. Have you looked at them? Like most Parallax products, there are links to the documentation and sample code on the product page in the webstore.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BWIN ON DA POWAH WIFIN U!!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
How would you change the code slightly to find the shortest distance instead? that way you could know the furtherest and the closest. Hope you don't mind me asking.
Thanks.
IF (inches < LOW) THEN ' THIS IS WHERE COMPARISON IS MADE
LOW = inches
XLOW = C ' XLOW holds at what measurement position( 1- 5) that was taken
ENDIF
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
-Phil
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"THE ONLY TRUE WISDOM IS IN KNOWING YOU KNOW NOTHING." - SOCRATES
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
BWIN ON DA POWAH WIFIN U!!!