PDA

View Full Version : Need help writing some code



sam_sam_sam
08-14-2005, 09:31 PM
......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 (mailto:jwilliams@parallax.com)
'·· Started....
'·· Updated.... 27 JUL 2005
'
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
-[ I/O Definitions ]---

Ping1·········· PIN···· 12
Ping2·········· PIN···· 13
PingBase······· CON···· 12······················ ' for use in Get_Sonar
-[ 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

-[ 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
·· -----[ 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
http://forums.parallax.com/images/smilies/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

........http://forums.parallax.com/images/smilies/jumpin.gif This GUY has gone MAD ..........

Bruce Bates
08-14-2005, 09:49 PM
Sam -

With a camera already in place (as I also had in my application) I found this VMD-19 video motion sensor chip to be a much more cost effective and easier solution to the same problem you're working with. Here is a link to the chip:
http://www.saelig.com/miva/merchant.mvc?Screen=PROD&Product_Code=VI001&Category_Code=VI

Regards,

Bruce Bates

sam_sam_sam
08-14-2005, 11:03 PM
HI Bruce

THANKS for web page site I will be odering very soon

sam

sam_sam_sam
08-14-2005, 11:14 PM
Hi evey one

I am going to use a VMD-19 video motion sensor chip for this project and not a ping sensor

THANKS Bruce for your help


sam