Voila le code :
Code:int temp_res; char temp[12]; unsigned int rtemp=10; char ntemp[10]; sbit LCD_RS at RB2_bit; sbit LCD_EN at RB3_bit; sbit LCD_D4 at RB4_bit; sbit LCD_D5 at RB5_bit; sbit LCD_D6 at RB6_bit; sbit LCD_D7 at RB7_bit; sbit LCD_RS_Direction at TRISB2_bit; sbit LCD_EN_Direction at TRISB3_bit; sbit LCD_D4_Direction at TRISB4_bit; sbit LCD_D5_Direction at TRISB5_bit; sbit LCD_D6_Direction at TRISB6_bit; sbit LCD_D7_Direction at TRISB7_bit; Lcd_Cmd(_LCD_FIRST_ROW); void adc() { temp_res = ADC_Read(2); // Get 10-bit results of AD conversion temp_res = (temp_res *5)/10; IntToStr(temp_res,temp); } void print() { delay_ms(5); Lcd_Cmd(_LCD_CLEAR); delay_ms(5); lcd_out(1,1,"Temp Reel") ; delay_ms(5); lcd_out(2,1,"Cons temp") ; delay_ms(5); } void test() { if(temp_res>rtemp) { PORTC=0b00000101; //cool } if(temp_res<rtemp) { PORTC=0b00001010;//hot } if(temp_res==rtemp) { PORTC=0x00; } } void main() { TRISA =0b10; TRISD =0x11; TRISC =0x00; Lcd_Init(); delay_ms(50); Lcd_Cmd(_LCD_CURSOR_OFF); delay_ms(50); //////////////////////////////// lcd_out(1,4,"Controle") ; delay_ms(50); lcd_out(2,1,"de Temperature") ; delay_ms(1500); Lcd_Cmd(_LCD_CLEAR); lcd_out(1,4,"Realise par") ; delay_ms(50); lcd_out(2,4,"Hadoudi") ; delay_ms(1500); Lcd_Cmd(_LCD_CLEAR); lcd_out(1,4,"Chouklati") ; delay_ms(50); lcd_out(2,4,"Farissi") ; delay_ms(1500); Lcd_Cmd(_LCD_CLEAR); lcd_out(1,4,"Encadre Par:") ; delay_ms(50); lcd_out(2,4,"Benboujemaa") ; delay_ms(1500); Lcd_Cmd(_LCD_CLEAR); lcd_out(1,4,"Souhane") ; delay_ms(50); lcd_out(2,4,"2011/2012") ; delay_ms(1500); print(); do { IntToStr(rtemp,ntemp); lcd_out(2,10,ntemp); delay_ms(200); lcd_out(1,10,temp) ; delay_ms(200); test(); if(portd.f1==0 && rtemp>0) { rtemp--; delay_ms(200); } if(portd.f0==0&&rtemp<=100) { rtemp++; delay_ms(200); } adc(); } while(1); return; }



Poursuivez votre recherche :



