J'apprends la programmation de pics, voici mes 2 question2: est ce qu'il y a une fonction specifique dans c pour arrondir les chiffres? je utilise
un capteur de temperature LM35 et pic16f877. Le but est de mesurer la température negative aussi et ne garder qu'un chiffre après la virgule. J'ai vu en faisant des recherches la fonction math roud que j'ai pas trouvé dans Mikro c.
La 2 eme question est: que fait ce 39 dans cette ligne Lcd_Chr(2,9,39);
Code : Tout sélectionner
// 21.02.2017 thermometre a PIC16F877A
// LCD module connections
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;
// End LCD module connections
unsigned int adc_rd; // Declare variables
char temp[15]; // Declare variables
long tension1; // Declare variables
long tension2; // Declare variables
long difference;
long valeur_final;
void main() {
INTCON = 0; // All interrupts disabled
ADCON1 = 0X82; // Configure AN0 et AN1 as input adc
CMCON = 0X7; // Disable comparators
TRISA = 0xFF; // PORTA configuré en entrée
Lcd_Init(); // LCD display initialization
Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off)
Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD)
Delay_ms(500);
while (1) {
adc_rd = ADC_Read(0); //lire entrée RA0
tension1 = ADC_Read(0);
adc_rd = ADC_Read(1); //lire entrée RA1
tension2 = ADC_Read(1);
difference = (tension1-tension2);
valeur_final =(difference* .488);
floattostr (valeur_final,temp);
Lcd_Chr(2,9,39);
Lcd_out(2,5,temp);
Delay_ms(200);
}
} 

00 et donne 2730mV à 0°C
