Code: Select all
'06/24/2010 For any Sony W series cam that is set to multiple image mode
'This will get more false triggers but it will also get the fastest trigger possible.
'Simple Snapshot Sniper board
'BEGIN USER INPUT
'****************************
symbol NightValue=7 'determined by experiment
symbol DayValue=10 'determined by experiment
symbol RefreshTime=63726 'timed about 6 minutes hours
symbol RefreshCounter=20 'multipy by RefreshTime for total refresh time 20 * 6 minutes =120 minutes
symbol RefreshOnTime=4 '2.3 times this number seconds to keep camera on during refresh
symbol TurnOffCamTime=45 'if camera is on and no motion turn off after this many seconds
symbol WalkAwayTime=130 '2.3 times this number in seconds. I made this big enough so cam will
'turn off if it happens to accidently be on when started.
'****************************
'END USER INPUT
symbol ShutterPin=0
symbol CameraPowerPin=1
symbol DayNightSensor=2
symbol DayNightSensorPin=pin2
symbol MotionSensorInput=3
symbol MotionSensorInputPin=pin3
symbol CameraIsONorOFF=bit0
symbol DayLight=bit1
symbol MeasuredLightValue=b3
symbol RefreshTime2=W3
symbol TurnOff=W4
symbol RefreshCounter2=W5
symbol CamIsOff=0
symbol CamIsOn=1
TurnOff=TurnOffCamTime * 165
TurnOff=RefreshTime - TurnOff
RefreshTime2=RefreshTime
RefreshCounter2=RefreshCounter
disablebod
low ShutterPin
low CameraPowerPin
input DayNightSensor
input MotionSensorInput
CameraIsONorOFF = CamIsOff
DayLight = 0
sleep 10
gosub refresh
sleep WalkAwayTime
setint %00000000,%00001000
Do
readadc DayNightSensor,MeasuredLightValue 'read the light value
'debug MeasuredLightValue
if MeasuredLightValue < NightValue then 'if too dark Daylight = 0
DayLight = 0
'low 4
end if
if MeasuredLightValue > DayValue then 'if light enough Daylight = 1
if DayLight = 0 then gosub refresh
DayLight = 1
'high 4
end if
'DayLight = 1
dec RefreshTime2 'refresh time
if RefreshTime2 < 1 then
RefreshTime2=RefreshTime
dec RefreshCounter2
if RefreshCounter2 < 1 then
RefreshCounter2=RefreshCounter
if DayLight = 1 then gosub refresh
end if
end if
if RefreshTime2 < TurnOff and CameraIsONorOFF = CamIsOn then gosub powerpress
Loop
refresh:
if CameraIsONorOFF = CamIsOff then gosub powerpress
sleep RefreshOnTime
if CameraIsONorOFF = CamIsOn then gosub powerpress
return
powerpress:
high CameraPowerPin
pause 400
low CameraPowerPin
if CameraIsONorOFF = CamIsOff then
CameraIsONorOFF = CamIsOn
else
CameraIsONorOFF = CamIsOff
end if
RefreshTime2=RefreshTime
RefreshCounter2=RefreshCounter
return
interrupt:
setint %00000000,%00000000 'turn off interrupt
if DayLight = 1 then
if CameraIsONorOFF = CamIsOff then gosub powerpress
high ShutterPin
sleep 2
low ShutterPin
pause 1500
RefreshTime2=RefreshTime
RefreshCounter2=RefreshCounter
end if
setint %00000000,%00001000 ‘ 're-activate interrupt
return ‘ 'return from sub