/* Voltmetre, on affiche la tension réglée grace à un potentiometre*/ #include #include #include #include interrupt[ADC_INT]void adc_isr(void); void brdInit(void); unsigned int tension; // float tension; unsigned char tampon[20]; void main (void) { brdInit(); #asm("sei") ADCSRA|=0x40; //on lance une seule fois la conversion while(1) { PORTD.5=1; PORTD.5=0; } } void brdInit(void) { #asm .equ __lcd_port=0x15 #endasm lcd_init(16); lcd_clear(); ADMUX=0b01000001; // AVCC with external capacitor at AREF pin // ADLAR = 0 // Entrée ADC1 ADCSRA=0b10101110; SFIOR=0x00; PORTD=0x00; DDRD =0b00110000; } interrupt[ADC_INT]void adc_isr(void) { lcd_gotoxy(0,0); lcd_putsf(" Entree ADC1 :"); tension=ADCW; // Valeur sur 10 bits de 0 à 1024 // il met le resultat de 2x8 bits bout a bout sprintf(tampon,"V = %4d<-- ",tension); lcd_gotoxy(0,1); lcd_puts(tampon); //on affiche delay_ms(10); }