#ifndef F_CPU #define F_CPU 16000000UL // telling controller crystal frequency (16 MHz AVR ATMega328P) #endif #include //header to enable data flow control over pins. Defines pins, ports, etc. #include //header to enable delay function in program #define BUTTON1 2 // button switch connected to port B pin 2 #define DEBOUNCE_TIME 25 // time to wait while "de-bouncing" button #define LOCK_INPUT_TIME 300 // time to wait after a button press // Timer0, PWM Initialization void timer0_init() { // set up timer OC0A,OC0B pin in toggle mode and CTC mode TCCR0A |= (1 << COM0A1)|(1 << COM0B1)|(1 << WGM00)|(1 << WGM01); // set up timer with prescaler = 256 TCCR0B |= (1 << CS02); // initialize counter TCNT0 = 0; // initialize compare value OCR0A = 0; } // ADC Initialization void ADC_init() { // Enable ADC, sampling freq=osc_freq/128 set prescaler to max value, 128 ADCSRA |= (1<