How would to do a code to make it so a group of leds are on until the PIR is triggered, and when the PIR is triggered the leds turn off
Is it a toggle effect? In other words, it initially has the LEDs on and when the PIR senses the trigger it turns them off, and then on the next trigger turns them back on and so on? Is there a minimum delay between turning the LEDs on and off?
Quote from: bigrez on March 10, 2009, 03:05:09 PM
Is it a toggle effect? In other words, it initially has the LEDs on and when the PIR senses the trigger it turns them off, and then on the next trigger turns them back on and so on? Is there a minimum delay between turning the LEDs on and off?
yea the leds would be on when ever the trigger has not been triggered they leds would only go on before and after the routine is done
I also need to make the leds to flash like strobe lights
OK,
Although this seems to work on my trainer, Jon (and others) probably has a much better way of doing this. If so, we'd both get to learn! :) (Wasn't sure if you wanted them to strobe when the trigger is active or when not active. The following has them strobing when triggered. A simple change will make it work the other way.)
' =========================================================================
' File......ledTrigStrobe.bs1
' Purpose...
' Author.... M. Resnick
' E-mail....
' Started... 10 MAR 2009
' Updated...
'
' {$STAMP BS1}
' {$PBASIC 1.0}
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL PIR = PIN6 ' SETUP = DN
SYMBOL LED = PIN0
' -----[ Constants ]-------------------------------------------------------
' -----[ Variables ]-------------------------------------------------------
SYMBOL timer = B2
SYMBOL strobe = B3
' -----[ Initialization ]--------------------------------------------------
Reset:
DIRS = %00011111
PAUSE 10000 ' 5 second PIR warm-up
' -----[ Program Code ]----------------------------------------------------
Main:
timer = 0
strobe = %00011111
PINS = strobe
Check_Trigger:
PAUSE 10 ' loop pad
timer = timer + 10 * PIR ' update timer
IF timer = 0 THEN Main ' wait for 0.1 sec input
strobe = strobe ^ %00011111 'Flip the bits
PINS = strobe ' set the bits on (or off)
PAUSE 25 ' Change this to get a slower flicker
GOTO Check_Trigger
' -----[ Subroutines ]-----------------------------------------------------
' -----[ User Data ]-------------------------------------------------------
alright i think I added the code correctly
File....... Steamer_Trunk.BS1
' Purpose.... Outcome of when PIR sensor is tiggered
' Author..... Joseph (Lotus) Lajoie
' E-mail..... Joey7252@yahoo.com
' Started....
' Updated....
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL WHITE = PIN0 ' V+/OUT0
SYMBOL UV = PIN1 ' V+/OUT1
SYMBOL GREEN = PIN2 ' V+/OUT2
SYMBOL JUMPER = PIN3 ' V+/OUT3
SYMBOL SPRAYER = PIN4 ' V+/OUT4
SYMBOL Trigger = PIN6 ' P6; SETUP = DN
' -----[ Constants ]-------------------------------------------------------
SYMBOL IsOn = 1
SYMBOL IsOff = 0
SYMBOL IsUp = 1
SYMBOL IsDown = 0
' -----[ Variables ]-------------------------------------------------------
SYMBOL timer = B2
SYMBOL strobe = B3 '
' -----[ Initialization ]--------------------------------------------------
Reset:
PINS = %00000000 ' clear everything
DIRS = %00000111 ' set outputs
PAUSE 10000 ' 10 second PIR warm-up
' -----[ Program Code ]----------------------------------------------------
Check_Trigger:
PAUSE 10 ' loop pad
timer = timer + 10 * PIR ' update timer
IF timer = 0 THEN Main ' wait for 0.1 sec input
UV = IsON
GOTO Check_Trigger
Main:
RANDOM lottery ' stir random value
IF Trigger = IsOff THEN Main ' wait for trigger
UV = IsOff ' UV LEDS OFF
PAUSE 2500 ' Wait 2.5 secs
White = IsOn ' White LEDS ON
strobe = strobe ^ %00011111 'Flip the bits
PINS = strobe ' set the bits on (or off)
PAUSE 25 ' Change this to get a slower flicker
PAUSE 1000 ' Wait 1 Sec
JUMPER = IsUp ' JUMPER IS UP
GREED = IsOn ' GREEN LEDS ON
PAUSE 500 ' Pause .5 Secs
SPRAYER = IsOn ' SPRAYER ON
PAUSE 3000 ' Wait 3 Secs
SPRAYER = IsOff ' SPRAYER is OFF
PAUSE 1000 ' Wait One Sec
White = IsOff ' White LEDS OFF
Greeb = IsOff ' GREEN LEDS OFF
PAUSE 1000 ' Wait 1 Sec
JUMPER = IsDown ' Jumper is Down
Long_Delay:
PAUSE 60000 ' one minute
GOTO Check_Trigger
I don't think that program is going to do what you want -- you have troubles in the trigger section and the strobe is not strobing. If you'll write out a detailed description of how the program is supposed to behave I will show you how to code it. It's a little tricky to do strobing while independently controlling other outputs but it can be done.
The UV leds will be on until the prop is triggered. Once triggered the UV led turn off and the white leds begin to strobe, while the white leds are strobing the green leds turn on and the skeleton jumps, and sprays water. and then returns to its normal position. The white leds stop and the prop goes into stand by until triggered again and the UV leds go on again I hope thats helps
Incase that is not detailed enough
Before Triggered
The UV LEDs are on until triggered
After being Trigger
The UV LEDs turn off and the white LEDs turn on and begin to strobe
after 2 second the Green leds turn on and the skeleton jumps
1 second after that the sprayer goes on for 3 seconds.
After this is done the green leds turn off and the skeleton returns to standby positon the white leds go for 2 more seconds
and then turn off. the prop can't be triggered again for 1 minute but the UV LEDs are on until the prop is triggered again
Thanks for All your help bigrez and JonnyMac
Ahhhh... quite a bit larger in scope than what was originally asked. :(
Quote from: bigrez on March 10, 2009, 05:54:14 PM
Ahhhh... quite a bit larger in scope than what was originally asked. :(
yea sorry about not saying everything that needed to be done
Give this try on your Prop-1 Trainer. We can adjust the strobe rate without impact on the rest of the program since your timing is pretty straightforward.
NOTE: Comment out the PAUSE 60000 during testing desk testing with the Prop-1 Trainer; no need to wait.
' =========================================================================
'
' File......
' Purpose...
' Author.... Jon Williams, EFX-TEK
' E-mail.... jwilliams@efx-tek.com
' Started...
' Updated... 10 MAR 2009
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' -----[ Program Description ]---------------------------------------------
' -----[ Revision History ]------------------------------------------------
' -----[ I/O Definitions ]-------------------------------------------------
SYMBOL Trigger = PIN6 ' P6; SETUP = DN
SYMBOL Sprayer = PIN4 ' V+/OUT4
SYMBOL Jumper = PIN3 ' V+/OUT3
SYMBOL Green = PIN2 ' V+/OUT2
SYMBOL UV = PIN1 ' V+/OUT1
SYMBOL White = PIN0 ' V+/OUT0
' -----[ Constants ]-------------------------------------------------------
SYMBOL IsOn = 1 ' for active-high in/out
SYMBOL IsOff = 0
SYMBOL Yes = 1
SYMBOL No = 0
' -----[ Variables ]-------------------------------------------------------
SYMBOL idx = B2
SYMBOL timer = W5
' -----[ Initialization ]--------------------------------------------------
Reset:
PINS = %00000010 ' start with UV on
DIRS = %00011111 ' set outputs
PAUSE 60000 ' remove for testing
' -----[ Program Code ]----------------------------------------------------
Main:
timer = 0 ' reset timer
Check_Trigger:
PAUSE 5 ' loop pad
timer = timer + 5 * Trigger ' update timer
IF timer < 100 THEN Check_Trigger ' wait for 0.1 sec input
Run_Prop:
UV = IsOff
timer = 2000
GOSUB Strobe_Delay
Green = IsOn
Jumper = IsOn
timer = 1000
GOSUB Strobe_Delay
Sprayer = IsOn
timer = 3000
GOSUB Strobe_Delay
Sprayer = IsOff
Jumper = IsOff
Green = IsOff
timer = 2000
GOSUB Strobe_Delay
GOTO Reset
' -----[ Subroutines ]-----------------------------------------------------
' Put delay time (milliseconds) in "timer" before calling
' -- strobe timing (delay resolution) is 100ms
Strobe_Delay:
IF timer < 100 THEN SD_Exit ' abort if expired
PINS = PINS ^ %00000001 ' strobe white
PAUSE 100 ' insert delay
timer = timer - 100 ' update timer
GOTO Strobe_Delay
SD_Exit:
RETURN
' -------------------------------------------------------------------------
' -----[ User Data ]-------------------------------------------------------
Works great on the prop 1 trainer
The code work awesome on the prop also just need to hook up all the electrics in the project box and i will post a video soon
I rule! ;D
Do post a video -- and tell your friends about EFX-TEK!
I'd be interested in the sprayer function... what did you use for that mechanism?
The sprayer mechanism is still in its test stage. I am using a "Y" Union connector one pipe to water 1 pipe to air and I get a good stream of water but now i am working on making a plug with a micro hole in it to cause a mist.
for the sprayer function i found that the secret is to use a this part http://www.exair.com/en-US/Products/Pages/Product%20Detail.aspx?pid=P810002&category=E-Vac&catalog=Vacuum+Generators&bc=Vacuum%20Generators;E-Vac&Vacuum%20Generators;E-Vac&vid=810006
it is just what the pros use
(http://img.photobucket.com/albums/v650/LotusMA/Steamer Trunk/th_SteamerTrunk2.jpg) (http://smg.photobucket.com/albums/v650/LotusMA/Steamer Trunk/?action=view¤t=SteamerTrunk2.flv)
Here you go just need to finish a few more things
Lotus:
That is pretty cool looking!
Good job!