Shop OBEX P1 Docs P2 Docs Learn Events
Ping))) detect person — Parallax Forums

Ping))) detect person

macgyverdt007macgyverdt007 Posts: 5
edited 2008-03-17 15:53 in BASIC Stamp
newbie here so i apologize ahead of time if this has already been discussed.

i am building a Ping project where i want it to notice if a person is a certain distance from it for a given amount of time to turn on a light.
ALA " if distance is 20 cm for 8 sec then activate light". i have attached my code so far to this. any help would be much appreciated. thank you so much

' {$STAMP BS2}
' {$PBASIC 2.5}
' Conversion constants for room temperature measurements.
CmConstant CON 2260
cmDistance VAR Word
time VAR Word
DO
PULSOUT 15, 5
PULSIN 15, 1, time
cmDistance = CmConstant ** time
DEBUG HOME, DEC3 cmDistance, " cm"
IF cmDistance = <20 THEN
PAUSE 3000
HIGH 13
PAUSE 3000
LOW 13
PAUSE 100
LOOP

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2008-03-17 15:53
    One thing to keep in mind when using the PING to detect people is that your readings are going to be erratic at best. People (skin) and clothing don’t reflect sound very well and will cause you to get inconsistent results.· Note also that in your code, you have an incomplete IF...THEN block.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
Sign In or Register to comment.