Sometimes, usually because of high power drawing devices, it is expedient to turn on a device for a day and then turn it off for several days to conserve power.  The CS725 SWE sensor is one such device.  It can be turned Off/On using the SW12 port on a datalogger, but when on, must be left on for >24 hrs to capture accurate readings.

'CR1000 Series Datalogger
' Written by: Robert Herfst, Campbell Scientific (Canada) Corp.
 
'The following program allows a user to set the number of DaysOff they want to 
'keep a CS725 off then turn it on for a day, then off again for the set number of days.
'When connected to the logger, type in the required number of days off beside the
'public variable named "DaysOff".
 
Public DaysOff
Public Counter, DayCount
Public  CS725On_Off As Boolean
Public DailyCounterFlag As Boolean
 
PreserveVariables
 
BeginProg
	CS725On_Off=true
	Scan (5,Sec,0,0)
	 
		If DailyCounterFlag=True Then
			If TimeIntoInterval (10,1440,Min) Then DayCount=DayCount+1
		EndIf
	 
	If DayCount=DaysOff Then CS725On_Off=True
	 
	If CS725On_Off=true Then
		If TimeIntoInterval (1435,1440,Min) Then
			SW12 (1 )
			Counter=Counter+1
		EndIf
		If Counter =2 Then
			If TimeIntoInterval (5,1440,Min) Then
				SW12 (0 )
				CS725On_Off=False
				Counter=0
				DayCount=0
				DailyCounterFlag=True ' When CS725 turned off, turn on DailyCounter
			EndIf
		EndIf
	EndIf
NextScan
EndProg