I want to blink an led using the 'timer' peripheral on atmega8. But the delay between switching of the led is to be determined by an analog voltage applied on port C 5.
The program attached is to do the following function-
1. Initialise the ADMUX register to use port C 5 as input of analog voltage, with Aref as the reference voltage.
2. Initialize the timer0 on the chip to start counting
3. Enclose adc start in single conversion mode in a while loop
4. A variable 'volt' stores the result of the a/d conversion (only ADCH is read, last 2 lsb's are ignored)
5. The Timer0 Overflow interrupt, when triggered, switched the adc interrupt off, reads value of 'volt' and appropriately sets the delay period of the led switching
But this isnt working. Can you tell me where i made a mistake?