// Auteur: VB // Date: 09/05/2019 // Description: lecture ADCvoie0 portA bit 0 (J1_0) // affichage sur LCD // sur clign sur RC0 (J3_0) // Test configuration: // MCU: PIC16F887 // Dev.Board: celle de THierry // Oscillator: HS, 20.0000 MHz // SW: mikroCpro for PIC // NOTES: fonctionne, // déclaration pour pour utiliser l'afficheur sbit LCD_RS at RB0_bit; sbit LCD_EN at RB1_bit; sbit LCD_D4 at RB2_bit; sbit LCD_D5 at RB3_bit; sbit LCD_D6 at RB4_bit; sbit LCD_D7 at RB5_bit; sbit LCD_RS_Direction at TRISB0_bit; sbit LCD_EN_Direction at TRISB1_bit; sbit LCD_D4_Direction at TRISB2_bit; sbit LCD_D5_Direction at TRISB3_bit; sbit LCD_D6_Direction at TRISB4_bit; sbit LCD_D7_Direction at TRISB5_bit; // fin déclaration pour utiliser l'afficheur unsigned int alpha,ADC0_int; char *valeur[13]; void main() { // utile dans old version, pas utile ici ... normalement //ADCON0 = 0x00; //ADCON1 = 0x80; // Configure analog inputs /OK //TRISA = 0x0F; // PORTA is input pour bits0123 PORTB = 0; // Initialize PORTB TRISB = 0; // PORTB is output for LCD PORTC = 0; // Initialize PORTC = 0 TRISC = 0; // PORTC, bit0 is output for LED //Lcd_Config(&PORTB, 0, 1, 7, 5, 4, 3, 2);// Initialize LCD connected to PORTB Lcd_Init(); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off while(1){ PORTC.F0 = ~PORTC.F0; // inverse PORTC.bit0 Delay_ms(1000); // Delai de 1sec ADC0_int = Adc_Read(0); // Get results of AD conversion IntToStr(ADC0_int, valeur); Lcd_Cmd(_LCD_CLEAR); // Clear display Lcd_Out(1, 1, "ADC0="); // Print text to LCD, 1row, 1column Lcd_Out(1, 5, valeur); // Print text to LCD, 1row, 5column alpha = ADC0_int >>2; // div par 4 IntToStr(alpha, valeur); Lcd_Out(2, 1, "alpha="); Lcd_Out(2, 5, valeur); } // Boucle sans fin }