Jump to content
ghoot

Ssii Day/night Detection With Led

Recommended Posts

Had a few folks tell me that the day only SSII setups were still taking video/pics at night. Did some testing and saw the same thing. The same code works fine on the SS1 (after changing the pin 's for the LED), so I was scratching my head and just couldn't figure it out. Then, it hit me! I used a different resistor value going to the LED on the SSII than on the SS1, so the value of the reading is of course different...DUH! You can thank 1encore for "nudging" me to get this figured out. :P

 

Here's where the change is needed in the SSII code:

The "3" in this line needs to be changed.

 

If B1 < 3 Then

 

Changing it to a "1" detects when it's fairly dark. .5 works good for when it's still a little light, except, the picaxe code won't let you put in a decimal number. To get .5, you would think that you want to put 1/2 then, but nope, that only returns the integer, which is zero in this case. you have to use "1//2" because that returns the remained of .5. BUT, you still can't plug that in like this "If B1 < 1//2 Then", because you'll get a syntax error. So, somewhere near the start of your code, add "b3=1//2" and then in the light detect part, change it like this "If B1 < b3 Then" and that will be then .5 value. Of course you can play with any fraction in there for different results.

 

Here's the day night detection code for the SSII where it is set at 1/2 or .5.

                b3=1//2

        Input 2 'set lED to input
        Nap 4 'pause for 244ms
        Readadc 2 , B1 'read ADC of LED
        Low 2 'make sure LED it turned off
        Poke $1f , 0
        If B1 < b3 Then 'if B1 is less than set light value. you can experiment with this
                      ''it's Dark
        else 
                      'it's light
        end if

Share this post


Link to post
Share on other sites
 

Just for the record, I did not understand a word of that. I will most likely just pester you for an entire daytime only code and save it my picaxe code box.

Share this post


Link to post
Share on other sites
 
 
Just for the record, I did not understand a word of that. I will most likely just pester you for an entire daytime only code and save it my picaxe code box.

 

I think Gary said... if you didn't pay attention to fractions back in high school math class you are now screwed... :blink::lol:

 

I'm just kidding of course! Thanks for the update Gary! We appreciate your help and contributions greatly!!!!!!!!!!

Share this post


Link to post
Share on other sites
 

I can't believe Gary has time to help any of you. He has a full time job just keeping up with my goofy requests and questions. I would like to thank Gary as well for the endless help!

Share this post


Link to post
Share on other sites
 

Thanks guys. This is still fun most of the time. :lol:

 

Here's the complete code for a Type 1 cam. Change the shutter time for the type 2 and 3 to 1500 or 2000. With this code, in feeder mode, you'll get a 30 second video with about a 1 minute delay and day only. In trail mode, ir will work like it always has for still pics.

 

symbol ShutterPin=0
symbol CameraPowerPin=1
symbol TrailFeederSwitchPin=pin4
symbol MotionSensorInputPin=pin3
symbol LEDpin=2
'symbol PAXE=5
symbol ActivityMode=bit0 '0=off and 1 = on
symbol StartWithWalkTestONorOff=bit1
symbol CameraIsONorOFF=bit2 'keep track of camera being on or off for activity mode
symbol TimeToTurnCamOnToRefreshFlash=w3
symbol TmeWaitAfterCamOnToPresShuter=w4
symbol DelayBetweenPictures=w5
symbol TimeForWalkTestToEnd=w6 'delay for walktest
symbol i=b1
disablebod
Low ShutterPin
Low CameraPowerPin
Low LEDpin
input 4
CameraIsONorOFF = 0
Pause 5000            
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    
b3=1//2 '0.5 value for dark Change to 1 for waiting till it's darker 
TimeToTurnCamOnToRefreshFlash=25000    '25,000 = 1 hour, 50,000 = 2 hours with NAP3 (.144)
TmeWaitAfterCamOnToPresShuter=1200'"1.2 S"
StartWithWalkTestONorOff = 1  'on = 1 off = 0
DelayBetweenPictures=26 '26 = 60 seconds between pics in feeder    mode     
TimeForWalkTestToEnd = 208 'Time for  walktest   0.144 secondss for nap3(208x0.144 = 30 seconds)

'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++    
Walktst:
IF StartWithWalkTestONorOff = 1 Then
    w1=w1+1 
    NAP 3
    IF MotionSensorInputPin = 1 Then
        High LEDpin
        Pause 1000
        Low LEDpin
        Pause 3000 'for sensor to settle
        w1=0
    EndIF
    IF w1 >=TimeForWalkTestToEnd Then
        StartWithWalkTestONorOff = 0
        For i = 1 to 10
            High LEDpin
            Pause 200
            Low LEDpin
            Pause 100
        next i
        Pause 1000
        GoTo lowpower
    EndIF
EndIF
GoTo Walktst
lowpower:
IF MotionSensorInputPin=1 Then

    IF CameraIsONorOFF=0 Then
        Pause 10
        IF TrailFeederSwitchPin = 1 Then
            ActivityMode=0
        Else
            ActivityMode=1
        EndIF
    EndIF
    IF ActivityMode = 0 Then
    
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        
        'check_light:
        Input 2 'set lED to input
        Nap 4 'pause for 244ms
        Readadc 2 , B1 'read ADC of LED
        Low 2 'make sure LED it turned off
        Poke $1f , 0
        If B1 < b3 Then 'if B1 is less than set light value. you can experiment with this
            pause 3000 '*pause for 3 seconds then go to standby. Change value to increase or decrese time between checking for light
        Else
            'goto take_picture
        
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
        'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    
    
'Record 30 second video
            If CameraIsONorOFF=0 Then
                Pause 10    
                High CameraPowerPin                ' Turn Camera ON
                Pause   1200
                Low CameraPowerPin
                CameraIsONorOFF=1
                Pause   4500
            endif
            High ShutterPin            ' Take a Picture
            Pause 1400
            Low ShutterPin
            Sleep 14
            High ShutterPin            ' Take a Picture
            Pause 1400
            Low ShutterPin
            Pause 4000
            High CameraPowerPin                ' Turn Camera OFF
            Pause   1200
            Low CameraPowerPin
            CameraIsONorOFF=0
            w1=0
            Sleep DelayBetweenPictures
        
        
        EndIF
    EndIF
    IF ActivityMode = 1 Then
        IF CameraIsONorOFF=0 Then
            Pause 10    
            High CameraPowerPin                ' Turn Camera ON
            Pause   300
            Low CameraPowerPin
            CameraIsONorOFF=1
            Pause   TmeWaitAfterCamOnToPresShuter
        EndIF
        High ShutterPin            ' Take a Picture
        Pause 2500
        Low ShutterPin
        Pause   2000
        w1=0
    EndIF
    w2=0
EndIF
IF CameraIsONorOFF=1 Then
    w1=w1+1
    IF w1>=300 Then 'Keep Camera on for 30 seconds for Activity Mode
        High CameraPowerPin                ' Turn Camera ON
        Pause   1000
        Low CameraPowerPin
        CameraIsONorOFF=0
        w1=0
        Sleep 2
    EndIF
EndIF


w2=w2+1
IF w2 >= TimeToTurnCamOnToRefreshFlash Then
    High CameraPowerPin                ' Turn Camera ON
    Sleep 1
    Low CameraPowerPin
    Sleep 5
    High CameraPowerPin                ' Turn Camera ON
    Sleep 1
    Low CameraPowerPin
    w2=0
    Pause 1000
EndIF
NAP 3    
GoTo lowpower                ' Do it forever
End

Edited by ghoot

Share this post


Link to post
Share on other sites
 
 
 

Been experimenting with this code but I'm curious to know exactly what the following bolded part of the code means and if it's required:

 

b3=1//2 '0.5 value for dark Change to 1 for waiting till it's darker

 

Does it mean that you're saying "if the light level is less then B3, it's light out -->take take a picture. And I'd also be curious to know what the "Change to 1 for waiting till it darker" out means. Any insight would be appreciated. Thanks :)

Share this post


Link to post
Share on other sites
 
Been experimenting with this code but I'm curious to know exactly what the following bolded part of the code means and if it's required:

 

b3=1//2 '0.5 value for dark Change to 1 for waiting till it's darker

 

Does it mean that you're saying "if the light level is less then B3, it's light out -->take take a picture. And I'd also be curious to know what the "Change to 1 for waiting till it darker" out means. Any insight would be appreciated. Thanks :)

 

Anything after the apostrophe (bold part will be probably green in the editor program) is a comment put in by the code writer. It is just a note usually to help understand what is going on in the code. Anything after the apostrophe does nothin in the program. What it means if you want it to do or not do something when it's darker then make it a 1. It doesn't understand decimals if I remember correctly? That's why it's not .5 in the actual code. Hope this helps.

Share this post


Link to post
Share on other sites
 
 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×