// A to D test code // NOTE -- You MUST MOUNT the Aref jumper #include #include //I like these definitions #define begin { #define end } char Ain ; //raw A to D number void main(void) begin //init the A to D converter //channel zero/ left adj /EXTERNAL Aref //!!!CONNECT Aref jumper!!!! ADMUX = 0b00100000; //enable ADC and set prescaler to 1/128*16MHz=125,000 //and clear interupt enable //and start a conversion ADCSR = 0b11000111; //init the UART UCSRB = 0x18; UBRRL = 103; printf("starting...\n\r"); // measure and display loop while (1) begin //get the sample Ain = ADCH; //start another conversion ADCSR.6=1; //results to hyperterm printf("%d\n\r",Ain); end end