Ping))) detect person
macgyverdt007
Posts: 5
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
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 Savage
Parallax Tech Support