This ATtiny25-based automatic timer project is built to control a water sprinkler. The timeout delay is adjusted using a potentiometer, while the on/off operation of the timer is controlled through a tact switch.
On the software side, upon power up, the timer flashes the status light to count out the delay in minutes. 10 flashes correlates to 10 minutes. The ADC reads the potentiometer just during the power up and calculates the delay for further use. So to change the delay, you first unplug the timer, set the delay, then plug it back in. This way it will hopefully prevent accidental changes and noise from changing the delay. To use the timer, you press the button once – the timer starts, the valve opens and the status light turns on. After the delay has elapsed, the timer will shut off, valve closes and the status light shuts off. If you want to turn it off early, then you just push the button and everything turns off. I also made use of the watchdog timer to prevent software issues from keeping the valve open. In the event that a watchdog reset occurs, the initial startup code will catch it, begin flashing the power LED and prevent further use until being power cycled.