'This is a simple mains timer that draws zero power in the off state. '15.5 hours maximum time. Internally the timer counts in seconds 'but is set and displays in 1/2 hour increments. Change line 27 to alter this. '"Pause 2000" gives 1hr increments and 31hours max. "Pause 500" for 15min max 7.75 Hrs. 'line 20 is the display calulation. "Or 32" ensures the mains stays on. 'The timer interval can be changed while it is running by adjusting the pot. symbol MainsSwitch = 5 symbol SetTime = w0 symbol ElapsedTime = w1 symbol LED_Display = b13 symbol isStop = pin3 symbol isDisable_Timer = pin4 pause 1000 high MainsSwitch SetTime = 0 ElapsedTime = 0 do readadc 0,SetTime SetTime = SetTime / 32 * 1800 'Use the 5 MSB each count = 1/2 Hr for maximum time of 15.5 hours LED_Display = SetTime - ElapsedTime / 1800 or 32 let pins = LED_Display if isDisable_Timer = 0 then ignoreTimer if isStop = 0 then closeDown pause 1000 ElapsedTime = ElapsedTime + 1 loop until ElapsedTime >= SetTime goto closeDown ignoreTimer: LED_Display = 1 for b12 = 0 to 4 pins = LED_Display or 32 pause 100 LED_Display = LED_Display * 2 next b12 if isStop = 1 then ignoreTimer closeDown: low MainsSwitch end