السلام عليكم
ارجوا من الاخ winmad ان يقبل مني بعض التحسينات
في الكود لان الكود المرفق يعطي خطا باستعمال
المايكروسي و المهم الكود المصحح هو كالتالي
int temp_res;
char temp[12];
unsigned int rtemp=10;
char ntemp[10];
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()
{
LCD_INIT(&PORTB);
lcd_out(1,1,"temp Act") ;
lcd_out(2,1,"temp Ref") ;
lcd_cmd(LCD_CURSOR_OFF);
}
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;
TRISB=0X00;
lcd_init(&portb);
lcd_out(1,3,"Control de") ;
lcd_out(2,3,"temperature") ;
lcd_cmd(LCD_CURSOR_OFF);
delay_ms(2000);
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;
}
تقبل مني احتراماتي و تقديري
الاستاذ: طيبي جمال
من الجزائر