IS Garage Door Open or closed stop Lcd from blinking "Out of Range"
I·use this program to let me know when the Garage Door is open·.··
I· mounted··the ping sensor on Garage Door 10" from the floor.
It works very well.
I hope someone can use this![idea.gif](http://forums.parallax.com/images/smilies/idea.gif)
IS there a better·
then this one
' {$STAMP BS2}
' {$PBASIC 2.5}
Ping· PIN· 14
#SELECT $stamp
· #CASE BS2
·· Trigger·· CON· 5
·· Scale···· CON· $200
#ENDSELECT
RawToIn····· CON· 889
IsHIGH······ CON· 1
IsLow······· CON· 0
rawDist····· VAR·· Word
inches······ VAR·· Word
'LCD display
N9600······ CON··· $4054
I·········· CON··· 254
CLR········ CON··· 1
LINE2······ CON··· 192
L1_C7······ CON··· 128
'Lcd display blink to fast and to many times
PAUSE 2000···· '·I·am going try pause 5000 to stop the blinking
SEROUT 6,n9600,[noparse][[/noparse]I,CLR]
Reset:
· DEBUG CLS,
· "Parallax Ping)))Soar", CR,
· "====================", CR,
· CR,
· "Time (uS).....····· "
Main:
· DO
···· SEROUT 6,n9600,[noparse][[/noparse]I,CLR]
··· GOSUB Get_Sonar
··· inches = rawDist ** RawToIn
··· DEBUG CRSRXY, 15, 3,
········· DEC rawDist, CLREOL,
········· CRSRXY, 15, 4,
········· DEC inches, CLREOL
SEROUT 6,n9600,[noparse][[/noparse]I,LINE2,"·· ''inches"]
SEROUT 6,n9600,[noparse][[/noparse]I,LINE2,DEC inches]
IF inches > 09 THEN SEROUT· 6,n9600,[noparse][[/noparse]I,L1_C7,"· CLOSED"]
__________________________________________________
·___There is more code that was left out·because of space___
IF inches >___·THEN SEROUT ·6,n9600,[noparse][[/noparse]I,L1_C7,"____open· "]
········ __10-135__···10,20,30 and so on· ·· __10%-90%__
__________________________________________________
IF inches > 136 THEN SEROUT 6,n9600,[noparse][[/noparse]I,L1_C7," OUT OF RANGE"]
'Light LED OUTPUT
·IF inches > 10 THEN· LOW 2
·IF inches < 12 THEN· HIGH 2
PAUSE 900
LOOP
END
Get_Sonar:
Ping = IsLow
PULSOUT Ping, Trigger
PULSIN· Ping, Ishigh, rawDist
rawDist = rawDist */ Scale
rawDist = rawDist· / 2
RETURN
![yeah.gif](http://forums.parallax.com/images/smilies/yeah.gif)
Post Edited (sam_sam_sam) : 6/16/2005 11:54:18 PM GMT
I· mounted··the ping sensor on Garage Door 10" from the floor.
It works very well.
I hope someone can use this
![idea.gif](http://forums.parallax.com/images/smilies/idea.gif)
IS there a better·
![idea.gif](http://forums.parallax.com/images/smilies/idea.gif)
' {$STAMP BS2}
' {$PBASIC 2.5}
Ping· PIN· 14
#SELECT $stamp
· #CASE BS2
·· Trigger·· CON· 5
·· Scale···· CON· $200
#ENDSELECT
RawToIn····· CON· 889
IsHIGH······ CON· 1
IsLow······· CON· 0
rawDist····· VAR·· Word
inches······ VAR·· Word
'LCD display
N9600······ CON··· $4054
I·········· CON··· 254
CLR········ CON··· 1
LINE2······ CON··· 192
L1_C7······ CON··· 128
'Lcd display blink to fast and to many times
PAUSE 2000···· '·I·am going try pause 5000 to stop the blinking
SEROUT 6,n9600,[noparse][[/noparse]I,CLR]
Reset:
· DEBUG CLS,
· "Parallax Ping)))Soar", CR,
· "====================", CR,
· CR,
· "Time (uS).....····· "
Main:
· DO
···· SEROUT 6,n9600,[noparse][[/noparse]I,CLR]
··· GOSUB Get_Sonar
··· inches = rawDist ** RawToIn
··· DEBUG CRSRXY, 15, 3,
········· DEC rawDist, CLREOL,
········· CRSRXY, 15, 4,
········· DEC inches, CLREOL
SEROUT 6,n9600,[noparse][[/noparse]I,LINE2,"·· ''inches"]
SEROUT 6,n9600,[noparse][[/noparse]I,LINE2,DEC inches]
IF inches > 09 THEN SEROUT· 6,n9600,[noparse][[/noparse]I,L1_C7,"· CLOSED"]
__________________________________________________
·___There is more code that was left out·because of space___
IF inches >___·THEN SEROUT ·6,n9600,[noparse][[/noparse]I,L1_C7,"____open· "]
········ __10-135__···10,20,30 and so on· ·· __10%-90%__
__________________________________________________
IF inches > 136 THEN SEROUT 6,n9600,[noparse][[/noparse]I,L1_C7," OUT OF RANGE"]
'Light LED OUTPUT
·IF inches > 10 THEN· LOW 2
·IF inches < 12 THEN· HIGH 2
PAUSE 900
LOOP
END
Get_Sonar:
Ping = IsLow
PULSOUT Ping, Trigger
PULSIN· Ping, Ishigh, rawDist
rawDist = rawDist */ Scale
rawDist = rawDist· / 2
RETURN
![yeah.gif](http://forums.parallax.com/images/smilies/yeah.gif)
Post Edited (sam_sam_sam) : 6/16/2005 11:54:18 PM GMT