/* * main.c * * Created: 23.4.2013 22:13:52 * Author: mpirc */ #include void Init(); int ADConvert(char channel); int main() { int result; Init(); while(1) { result=ADConvert(2); //measure channel 2 (trimmer) PORTB=result>>2; //shift the result for 2 bits (lose the 2 least significant bits out of 10) } //before displaying it on the 8 bit PORTB. } void Init() { //IO port PORTA=0x08; //0000 1000 PORTB=0x00; //0000 0000 PORTC=0x3E; //0011 1110 PORTD=0x7D; //0111 1101 //1-output, 0-input DDRA=0xF0; //1111 0000 DDRB=0xFF; //1111 1111 DDRC=0xC1; //1100 0001 DDRD=0x82; //1000 0010 //ADC ADMUX=(1<