buckshot164

'Whitetail Whittle
'Eagle Eye Video Board
'DXG567 Code
'18M2 Picaxe Chip
'Array
'mic
'Exchanger
'15 second or 30 second videos with switch 1
'1 minute or 3 minute delay with switch 2
'Day/24HR Modes with switch 3


disablebod                
                                
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'18M2 Pin Out

'B.0    switch
'B.1    switch
'B.2    switch
'B.3    spare mosfet
'B.4    spare mosfet
'B.5    camera shutter
'B.6    camera power
'B.7    mic
'C.0    exchanger
'C.1      exchanger
'C.2     CDS "read light"
'C.3     CDS power
'C.4     program
'C.5    PIR
'C.6    Array
'C.7    LED

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'NAMING PINS

symbol video_length_switch =  PinB.0
symbol delay_switch = PinB.1
symbol day_24hr_switch = PinB.2
symbol spare_mosfet1 = B.3
symbol Exchanger_Power = B.4
symbol shutter = B.5
symbol campwr = B.6
symbol mic = B.7
symbol exchanger_day = C.0
symbol exchanger_night = C.1
symbol cds_read = PinC.2
symbol cds_power = C.3
symbol program = C.4
symbol pir = PinC.5
symbol array = C.6
symbol led = C.7

'NAMING VARIABLES

symbol Walktest_Timer = w0
symbol CDS_Value = b2
symbol Night_Flag = b3
symbol CDS_Day_Night = b4
symbol Exchanger_Position = b5
symbol Arm_Blinks = b7         'loop to blink led to show walktest complete

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'SETTING VARIABLES

CDS_Day_Night = 20           
Night_Flag = 1
Exchanger_Position = 1

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

'SETTING INPUTS/OUTPUTS

input b.0
input b.1
input b.2
output b.3
output b.4
output b.5
output b.6
output b.7
output c.0
output c.1
input c.2
output c.3
input c.4
input c.5
output c.6
output c.7

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Camera_Test:

high led                'power on led
sleep 2                    'pause 4 seconds
high array                'turn on array
gosub CamOn                'power camera on
sleep 2                    'turn cam on for 4 seconds
gosub exchangernight            'flip IR filter off
pause 1000                'pause 1 second
gosub exchangerday            'flip IR filter on
pause 1000                'pause 1 second
gosub CamOff                'power camera off
low array                       'turn off array
low led                    'power off led
pause 500                'pause 500 ms
goto Walk_test                'move to walk test

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Walk_test: 

Walktest_Timer = 300            '300 for 30 second walk test
Do While Walktest_Timer > 0                          
If Pir = 1 then                'if pir detects motion then
high led                'power on led
pause 1000                'keep led on for a 1 second
low led                    'power off led
Walktest_Timer = 300            'reset timer if walk test is interrupted
pause 3000                'wait 3 seconds for pir to settle
endif
Walktest_Timer = Walktest_Timer - 1    'decrease W0 timer by 1                              
pause 100                'pause 100 ms
loop
for Arm_Blinks = 1 to 4            'loop for 4 times to flash led to show walk test complete                                  
high led                'power on red led           
pause 500                'pause 1/2 second
low led                    'turn off led
pause 500                'pause 1/2 second
next Arm_Blinks
sleep 2                      
goto Main                'move to Main

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Main:        'CHECKS FOR MOTION

if Pir = 1 then            'if motion detected then
goto Cam_Functions        'go to take picture
endif
goto Main

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Cam_Functions:

gosub CdsChk            'check for day or night

if day_24hr_switch = 1 and Night_Flag = 1 then    'if in DAY ONLY mode and its night then continue looking for motion
goto Main
endif

gosub Check_Exchanger        'check exchanger position
   
'XXXXXXXXXXX NIGHT FUNCTIONS XXXXXXXXXXX

If Night_Flag = 1 Then        'if NIGHT then

gosub CamOn            'power on camera
pause 3000            'pause between power and shutter
high mic            'turn on mic
high array            'turn on array
gosub Record            'start recording
if video_length_switch = 1 then
pause 15000            'pause for 15 second videos
else
pause 30000            'pause for 30 second videos
endif
gosub Record            'stop recording
low mic                'turn on mic
low array            'turn off array
pause 5000            'pause after pic taken to save to card
gosub CamOff            'power off camera
endif               

'XXXXXXXXXXX DAY FUNCTIONS XXXXXXXXXXXX

if Night_Flag = 0 Then        'if DAY then

gosub CamOn            'power on camera
pause 3000            'pause between power and shutter
high mic
gosub Record            'start recording
if video_length_switch = 1 then
sleep 7                'pause for 16 second videos
else
sleep 13            'pasue for 30 second videos
endif
gosub Record            'stop recording
low mic
sleep 2                'pause after pic taken to save to card
gosub CamOff            'power off camera
endif

'XXXXXXXXXXX DELAY TIMES XXXXXXXXXXXXXX

if delay_switch = 1 then
sleep 26            '1min delay
else
sleep 78            '3 minute delay
endif

goto Main            'do it all over again

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Record:

high shutter       
pause 900            'pause 900 ms
low shutter           
return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

CamOn:  
          
high campwr                     
pause 900            'pause 900 ms
low campwr               
return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

CamOff:

high campwr
pause 900            'pause 300 ms
low campwr
return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ExchangerNight:

High Exchanger_Power
High exchanger_night
pause 100
Low exchanger_night
Low Exchanger_Power

Exchanger_Position = 1
Return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ExchangerDay:

High Exchanger_Power
High exchanger_day
pause 100
Low exchanger_day
Low Exchanger_Power

Exchanger_Position = 0
Return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Check_Exchanger:

If Night_Flag = 1 and Exchanger_Position = 1 Then
Endif

If Night_Flag = 1 and Exchanger_Position = 0 Then
Gosub ExchangerNight
Endif

If Night_Flag = 0 and Exchanger_Position = 1 Then
Gosub ExchangerDay
Endif

If Night_Flag = 0 and Exchanger_Position = 0 Then
Endif
Return

'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

CdsChk:

High cds_power                 'Turn on pin to supply voltage to cds voltage divider
readadc C.2, CDS_Value             'Read light value
Low cds_power                 'Turn off voltage divider

If CDS_Value <= CDS_Day_Night Then
Night_Flag = 1                'Night   
endif

If CDS_Value > CDS_Day_Night Then
Night_Flag = 0                'Day
endif

Return
Quote 0 0