/*********************************************************************** Program for counter. Program Written by MKDas Email: mithun060@gmail.com; ***********************************************************************/ // LCD module connections sbit LCD_RS at RA0_bit; sbit LCD_EN at RA1_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 TRISA0_bit; sbit LCD_EN_Direction at TRISA1_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; // End LCD module connections // Tact switches and Relay ports sbit Relay at RA3_bit; sbit SS_Select at RB0_bit; // Start Stop Timer Select sbit Unit_Button at RB1_bit; // Set unit min sbit Ten_Button at RB2_bit; // Set ten min // Messages char Message1[]="00-99 min Timer"; char Message2[]="RELAY ON"; char Message3[]="RELAY OFF"; char Message4[]="Set Time: min"; char Message5[]="Time Left: min"; unsigned short i, j, unit=0, ten=0, ON_OFF=0, index=0, clear, time; char *digit = "00"; // 300ms Delay void Delay_300(){ Delay_ms(300); } void Display_Digits(){ digit[1]=unit+48; digit[0]=ten+48; Lcd_Out(2,11,digit); } void start_timer(unsigned short MinVal){ unsigned short temp1, temp2; Relay = 1; ON_OFF = 1; Lcd_Cmd(_LCD_CLEAR); Lcd_Out(1,1,Message2); Lcd_Out(2,1,Message5); OPTION_REG = 0x80 ; INTCON = 0x90; for (i=0; i 0) start_timer(time); } // If !SS_Select if(clear){ goto start; } } while(1); }