Shop OBEX P1 Docs P2 Docs Learn Events
Need help writing some code — Parallax Forums

Need help writing some code

sam_sam_samsam_sam_sam Posts: 2,286
edited 2005-08-14 16:14 in BASIC Stamp
......HI .......
every one
...................
I realy like these PING sensors projects· I am using one for my· garage door to know if my door is open or
closed now i want to turn on my VCR on when there something is front a camera using two pings
sensors i need some help controling 3 relays to come on at different time and for 1 sec
below
·I have try two ways to do it
·Can not get it to work the way
·I want it to work
'·· File....... Ping2.BS2
'·· Purpose.... Reads four Ping sensors in round-robin fashion
'·· Author..... Jon Williams -- Parallax, Inc.
'·· E-mail..... jwilliams@parallax.com
'·· Started....
'·· Updated.... 27 JUL 2005
'
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
-[noparse][[/noparse] I/O Definitions ]---

Ping1·········· PIN···· 12
Ping2·········· PIN···· 13
PingBase······· CON···· 12······················ ' for use in Get_Sonar
-[noparse][[/noparse] Variables ]--
pingIdx········ VAR···· Nib···················· ' sensor index
thePing········ VAR···· Nib···················· ' sensor pin
rawDist········ VAR···· Word··················· ' raw measurement
inches········· VAR···· Word(2)
set············ VAR···· Word
set1··········· VAR···· Word

-[noparse][[/noparse] Program Code ]--

Main:
· DO
··· GOSUB Get_Sonar···························· ' read selected sensor
··· pingIdx = pingIdx + 1 // 2················· ' update index
···· DEBUG CRSRXY, 15, 3,
········· DEC rawDist, CLREOL,
········· CRSRXY, 15, 4,
········· DEC· inches, CLREOL
···· DEBUG CRSRXY, 20, 10,
········· DEC set, CLREOL
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
I am not sure if this is right way to this please let me know if this is not right
or if there is a better way to do this
··
·IF· set = 6000 THEN set = 0
·IF· set = 3000 THEN ledlight1
·IF rawdist < 1000 THEN set = set + 1
·IF· set >3 THEN set = set + 1
·IF· set = 5 THEN ledlight

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
·LOOP
· END
··
[noparse][[/noparse] Subroutines ]----
What i would like to know is if there i s a way to control the outputs with out using the PAUSE command
·This works but the ONE WITH OUT· SET1....
·I can only use·PAUSE 100... or·ANY HIGHER·the·LED BLINKS all the time
Now the one that use the SET1 work ok
I·want to do this control·OUTPUTS at diffrent COUNT POINTS let say at

..........10 count turn on one output for 1 sec· at..................
.......... 30 count turn on output two for 1 sec· at................
............3000 count turn on out put three for 1 sec...............
·when i have try to this it will STOP counting when it gets to the FRIST OUT PUT·
................note that i will be using RELAYS for LEDS....................
................note that....FOR set1=14 TO 14....... is to control more that ONE out put at the
same time i know this i was tring something......................
Can some one help with this project i would realy APRECIATE it
·I would like THANK ANY ONE· that can help this· project
idea.gif
···· ledlight:
····· FOR set1=14 TO 14·················· OR·················· ledlight:
·· HIGH set1································································ HIGH 14
·· NEXT·········································································· PAUSE 100···················
·· PAUSE 1000······························································ LOW 14
····· FOR set1=14 TO 14·············································· GOTO main
·· LOW set1
·· NEXT
· GOTO main


·· ledlight1:················································· OR·············· ledlight1:
····· FOR set1=15 TO 15··················································· HIGH 15
·· HIGH set1······································································· PAUSE 100
·· NEXT················································································ LOW 15
·· PAUSE 1000···································································· set = 0
····· FOR set1=15 TO 15···················································· GOTO main
·· LOW set1
·· NEXT
·· set = 0
· GOTO main

THANK YOU FOR ANY HELP THAT YOU CAN GIVE ME· IN THIS MATTER

·samsam

........jumpin.gif This GUY has gone MAD ..........

Comments

Sign In or Register to comment.