Jak napisać program w C do 2 zbiorników LCD w C Programming Language ?
Solution:
- //---------------------- Początek deklaracji użytkownika --------------------------------
- int tim1,tim2;
- char stan1=1,stan2=5,stanLCD=1;
- int T1=30,T2=10,T3=150;
- //-------------- Początek kodu użytkownika --------------------------------------
- switch(stan1){
- case 1: Z1=1; if (X2){stan1=2;tim1=T1;}
- break;
- case 2: Z1=1; if (X1){stan1=4;}
- else if (!X2){stan1=1;}
- else if (!tim1){stan1=3;tim1=T2;}
- break;
- case 3: Z1=0; if(!X2){stan1=1;}
- else if (!tim1){stan1=2;tim1=T1;}
- break;
- case 4: Z1=0; if(!X2){stan1=1;}
- break;
- }
- switch(stan2){
- case 5: Z3=1;Z5=0;M=0; if (X7){stan2=6;tim2=T3;}
- break;
- case 6: Z3=1;Z5=0;M=0;if (X5||!tim2){stan2=7;tim2=50;}
- break;
- case 7: Z3=0;Z5=0;M=1; if(!tim2){stan2=8;}
- break;
- case 8: Z3=0;Z5=1;M=0; if(!X7){stan2=1;}
- break;}
- if (tim1) --tim1;
- if (tim2) --tim2;
- //-------------- Wyświetlacz LCD --------------
- switch (stanLCD){
- case 1:LCD_xy(0,0);LCD_puts("Sterownik "); if (aK1)stanLCD=2;break;
- case 2:LCD_xy(0,0);LCD_puts("Timer ");
- sprintf(buf,"T1=%dT2=%dT3=%d",(int)T1,(int)T2,(int)T3);
- LCD_xy(0,1);LCD_puts(buf);
- if(aK1)stanLCD=3;
- else if (aK2) stanLCD=4;
- else if (aK3) stanLCD=5;
- break;
- case 3: LCD_xy(0,0);LCD_puts("T1 ");
- sprintf(buf,"%d - + ",(int)T1);
- LCD_xy(0,1);LCD_puts(buf);
- if(aK1)++T1;
- if(aK2)--T1;
- if(aK4) stanLCD=2;
- break;
- case 4: LCD_xy(0,0);LCD_puts("T2 ");
- sprintf(buf,"%d - + ",(int)T2);
- LCD_xy(0,1);LCD_puts(buf);
- if(aK1)++T2;
- if(aK2)--T2;
- if(aK4) stanLCD=2;
- break;
- case 5: LCD_xy(0,0);LCD_puts("T3 ");
- sprintf(buf,"%d - + ",(int)T3);
- LCD_xy(0,1);LCD_puts(buf);
- if(aK1)++T3;
- if(aK2)--T3;
- if(aK4) stanLCD=2;
- break;
- }