Nagbabakasakali lang po baka makatulongan nyo ako sa ginagawa kung countdown timer pagpinush ang button ay magstart na syang magdecreement, hindi ako gaanong shure sa pagkakagamit ko ng interrupt nagstart palang ako magaral nito, sana po matulongan nyo ako, ayaw pa kasing gumana nung code,no errors sya pero hindi nagdedecreement,at di rin natunog yung buzzer, bakit kaya
// LCD module connections
sbit LCD_RS at RA0_bit;
sbit LCD_EN at RA1_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISA0_bit;
sbit LCD_EN_Direction at TRISA1_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
sbit COINS at RA2_bit;
sbit Relay_Switch at RA3_bit;
char MSG1[]="Charging Device" ;
char MSG2[]="Not Charging";
char MSG3[]="HH:MM:SS";
unsigned short HHMMSS_Pos[]={3,4,5,6,7,8,9,10};
unsigned short TIME[]={0,0,10,0,0,10,0,0};
unsigned short i;
unsigned short Num,Sec,ChangeSec,Mint,ChangeMin,ChangeHour=0;
unsigned short Hour,Minute,Second;
void Disp_First_Row(){
if (Relay_Switch==0) Lcd_Out(1,1,MSG2);
if (Relay_Switch==1) Lcd_Out(1,1,MSG1);//
}
void Disp_Char(unsigned short col, unsigned short chr){
Lcd_Chr(2,col,chr+48);
}
void Disp_Time(){
for(i=0;i<8;i++){
Disp_Char(HHMMSS_Pos,TIME);}
}
void Play_Sound(){
Sound_Play(2500,500);}
void Debounce(){
Delay_ms(500);
}
void Disable_Timer(){
INTCON=0x00;
Relay_Switch=0;
INTCON.T0IF=0;
Disp_First_Row();
Disp_Time();
Play_Sound();
}
void interrupt(){
Num++;
if(Num==18){
Sec++;
ChangeSec=1;
Num=0;
if(Sec==60){
Mint++;
ChangeMin=1;
Sec=0;
if(ChangeMin=60){
ChangeHour=1;
Mint=0;
}
}
TMR0=39;
INTCON.T0IF=0; }
}
void main(){
CMCON=7;
TRISA=0b00100100;
TRISB=0b00000000;
Sound_Init(&PORTA,4);
Relay_Switch=0;
Num=0;
Sec=0;
ChangeMin=0;
ChangeHour=0;
i=0;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_Cursor_OFF);
Lcd_Out(1,1,"Charging Station");
Lcd_Out(2,1,"Welcome");
while(i<4){
Debounce();
i++;}
Lcd_Cmd(_LCD_CLEAR);
Disp_First_Row();
Disp_Time();
do{
if(COINS==0){
Debounce();
Play_Sound();
TIME[3]=2;
OPTION_REG=0x07;
TMR0=39;
INTCON=0xA0;
INTCON.T0IF=0;
Disp_Time();
}
Hour=Time[0]*10+Time[1];
Minute=Time[3]*10+Time[4];
Second=Time[6]*10+Time[7];
if(COINS==1){
if(ChangeMin==1){
if(Minute=0&&Hour>0){
Minute=59;
Hour--; } //Decrement
}
if(Hour=0&&Minute>0){
Minute--;}
if(ChangeMin==0)
if(ChangeSec=1){
if(Second=0&&Minute>0){
Second=59;
Minute--;}
if(Minute=0&&Second>0){
Second--;}
}
}
}while(1);
}