هذا البرنامج به مشكلة وارجو ممن عنده حل لها ان يطرحه
char m;
char w;
char result=0;
char result_t=0;
char number[]={'x',' ','9','8','7','x','6','5','4','x','3','2','1','x', 'x','0','x'};
char number2[]={'x',' ',9,8,7,'x',6,5,4,'x',3,2,1,'x','x',0,'x'};
char tens=0,ones=0;
char tens1=0,ones1=0;
unsigned long temp,aa;
int kk;
int x;
char txt[14];
///////////////////////////////// Controlling the relay according to the degree:
void on() {
result=(tens*10)+ones;
result_t=(tens1*10)+ones1;
if(result>99 || result<1){Lcd_Cmd(Lcd_Clear);lcd_out_cp("error");d elay_ms(1000);return;}
x=result_t/60;
while(1)
{
for(x=0; x<result_t; x--){
delay_ms(1000);
temp=adc_read(0);
temp=(temp*5000)>>10;
temp=temp/10;
longToStr(temp,txt);
lcd_out(1,1,"temp = ");
lcd_out(2,1,txt);
lcd_chr_cp('C');
delay_ms(500);
lcd_cmd(lcd_clear);
if(temp<result)
{
portd.f0=1;
}else {portd.f0=0;}
}
}
}
void main()
{
adcon1=0b00001110; // using Port A as analog to digital converting
trisa=0xff;// using Port A as in put
trisd=0;
Keypad_Init(&PORTC); // Using Port C for Keypad
lcd_init(&portb); // Using POrt B for LCD
lcd_cmd(LCD_CURSOR_OFF);
lcd_out(1,1,"Enter the Degree");
lcd_out(2,1," C");
/////////////////////////////////////Entering Degree
loop: //testing the first pushing down
m=keypad_read();
if(m==0) {goto loop;}
else if(m==14){goto loop;}
else if(m==16){Lcd_Cmd(Lcd_Clear);goto loop;}
else {Lcd_Cmd(Lcd_Clear);tens=number2[m];lcd_chr_cp(number[m]);delay_ms(500);}
test2: //testing the second pushing down
m=keypad_read();
if(m==0) {goto test2;}
else if(m==14){ones=tens;tens=0;on();goto test3;}
else if(m==16){Lcd_Cmd(Lcd_Clear);goto loop;}
else {ones=number2[m];lcd_chr_cp(number[m]);delay_ms(500);}
test3: //testing the third pushing down
m=keypad_read();
if(m==0) {goto test3;}
else if(m==14){goto loop2;}
else if(m==16){Lcd_Cmd(Lcd_Clear);goto loop;}
else {goto test3;}
}
/////////////////////////////////// Entering Time by mints
loop2: //testing the first pushing down
lcd_cmd(lcd_clear);
lcd_out(1,1,"Enter the Time");
w=keypad_read();
if(w==0) {goto loop2;}
else if(w==14){goto loop2;}
else if(w==16){Lcd_Cmd(Lcd_Clear);goto loop;}
else {Lcd_Cmd(Lcd_Clear);tens1=number2[m];lcd_chr_cp(number[m]);delay_ms(500);}
test2: //testing the second pushing down
w=keypad_read();
if(w==0) {goto test2;}
else if(w==14){ones1=tens;tens1=0;on();goto test3;}
else if(w==16){Lcd_Cmd(Lcd_Clear);goto loop;}
else {ones=number2[m];lcd_chr_cp(number[m]);delay_ms(500);}
test3: //testing the third pushing down
w=keypad_read();
if(w==0) {goto test3;}
else if(w==14){on();}
else if(w==16){Lcd_Cmd(Lcd_Clear);goto loop;}
else {goto test3;}
}