Voici le code que j'ai utilisé pour mes tests :
Code : Tout sélectionner
#define ADLAR (1<<5)
#define ADEN (1<<7)
#define ADSC (1<<6)
#define ADIF (1<<4)
int adc (int port)
{
int a;
ADCSRA |= ADEN;
// SFIOR = 0x00;
ADMUX = ADLAR | port;
ADCSRA |= ADSC;
while ((ADCSRA & ADSC) == ADSC);
a = ADCH;
return a;
}
void main (void)
{
DDRC = 0xFF;
DDRD = 0xFF;
while (1)
{
PORTC=adc(2);
//delay_ms (3000);
PORTD=adc(3);
//delay_ms (3000);
}
}
Merci pour votre aide.