If this is a dumb error on my part, I apologize. I am varying the voltage to an pinput pin (PORT C bit 0) and when the ADC reads 0xff I light an LED. Big deal! Should work right?
It is very unreliable. Sometimes it works, sometimes it does not. Mostly the LED is ON and I cannot get it go off. Hmmm..... Can anyone spot the bug? I surely wish I could see it.
unsigned char read_adc(unsigned char adc_input)
ADCSRA|=0x40; // Start the AD conversion
while ((ADCSRA & 0x10)==0); // Wait for the AD conversion to complete
unsigned char i;
InitHardware(); //Init IO ports
i=read_adc(PINC.0); //ADC input PORTC pin 0
if(i == 0xff)