unsigned int LectureVcons; void init() { TRISA = 0b00000001; // Configuration de la broche RA0 comme entrée PORTA = 0b00000000; // On met toutes les sorties du PORTA à "0" TRISB = 0b00000000; // Configuration du PORTB comme sortie PORTB = 0b00000000; // On met toutes les sorties du PORTB à "0" ANSEL = 0b00000001; // Configuration de l'entrée RA0 en analogique ADC_Init(); // Initialisation du convertissuer Analogique /numérique (A/N) } void Lecture_Vcons() { LectureVcons = ADC_Get_Sample(0); { if (LectureVcons > 102) PORTA.RA1 = 1; else PORTA.RA1 = 0; if (LectureVcons > 204) PORTA.RA2 = 1; else PORTA.RA2 = 0; if (LectureVcons > 306) PORTA.RA3 = 1; else PORTA.RA3 = 0; if (LectureVcons > 408) PORTA.RA4 = 1; else PORTA.RA4 = 0; if (LectureVcons > 510) PORTB.RB0 = 1; else PORTB.RB0 = 0; if (LectureVcons > 612) PORTB.RB1 = 1; else PORTB.RB1 = 0; if (LectureVcons > 714) PORTB.RB2 = 1; else PORTB.RB2 = 0; if (LectureVcons > 816) PORTB.RB3 = 1; else PORTB.RB3 = 0; if (LectureVcons > 918) PORTB.RB4 = 1; else PORTB.RB4 = 0; if (LectureVcons > 1020) PORTB.RB5 = 1; else PORTB.RB5 = 0; } } void main() { init(); while (1) { Lecture_Vcons(); } }