Can't get the ADC to work, ADCH=0xFF no matter what I do :(

It should be really simple, but I'm clearly missing something here :(

void setup() { ADMUX=0b01100000; //AVcc reference, ADLAR=1 (left adjusted), adc0 selected. ADCSRA=0b11100000; //ADEN=1 (ADC enable), ADSC=1 (ADC start conversion), ADATE=1 (Auto //trigger)

}

void loop() { if((ADCSRA&0b10000)==0b10000) { //Checks if the interrupt flag is high Serial.println(ADCH, BIN); ADCSRA=ADCSRA&0b10111111; //Clears the interrupt flag } }

The ADC seems to be running since it keeps raising the interrupt flag even after I reset it showing "ADC conversion complete", but the ADCH register is just filled with ones. Since ADLR=1 (left adjustment) it should be okay to just read the ADCH register, as the datasheet puts it: "Consequently, if the result is left adjusted and no more than 8-bit precision is required, it is sufficient to read ADCH.". Using analogRead(A0) works just fine so there are no hardware issues.

Does this help: http://electronics.stackexchange.com/questions/135876/atmega328p-adc-keeps-returning-1023

I had way too high of a clock speed, that's why I couldn't make it work.

ADCSRA=0b11100111; //Clock division factor of 128