sidang
Newbie level 5
hello everyone..i have a problem on my project.. My project is a digital clock with multi mode timer (3 different time of alarm)..Hope someone could help me..the problem is
i donno how to switch off / reset the LED during the alarm time..in other word: the LED will be on for 2 minute and i need to switch off the LED during that time..
this my code..
int S1, S2, c1, c2, c3, c4, c5, c6, a3, a4, a5, a6, e3, e4, e5, e6, m3, m4, m5, m6 ;
int i;
void main ()
{
PORTA=0;
PORTB=0;
PORTC=0;
TRISA=0;PORTA=0;
TRISB=0;
TRISC=0;
TRISD=255;
PORTD=0;
c1=0; c2=0; c3=0; c4=0; c5=0; c6=0;
a3=0; a4=1; a5=0; a6=0;
e3=0; e4=2; e5=0; e6=0;
m3=0; m4=3; m5=0; m6=0;
restart:
if (PORTD.F0==0 && PORTD.F1==1 && PORTD.F7==1 && PORTD.F6==1)
{
PORTB=c3+c4*16;
PORTC=c5+c6*16;
if (PORTD.F2==0 && PORTD.F3==1) {c3++;
if (c3==10)
{ c3=0;
c4=c4+1;
}
if (c4==6)
{c4=0;
c5=c5+1;
}
if (c5==10)
{c5=0;
c6=c6+1;
}
if (c6==2 && c5==4)
{c6=0;
c5=0;
}
Delay_ms(500);}
if (PORTD.F3==0 && PORTD.F2==1) {c5++;
//if (PORTD.F3==0 && PORTD.F2==0){c5++; c3++;}
if (c3==10)
{ c3=0;
c4=c4+1;
}
if (c4==6)
{c4=0;
c5=c5+1;
}
if (c5==10)
{c5=0;
c6=c6+1;
}
if (c6==2 && c5==4)
{c6=0;
c5=0;
}
Delay_ms(500);}
goto restart;
}
else if(PORTD.F0==1 && PORTD.F1==0 && PORTD.F7==1 && PORTD.F6==1)
{
PORTB=a3+a4*16;
PORTC=a5+a6*16;
if (PORTD.F2==0 && PORTD.F3==1) {a3++;
if (a3==10)
{ a3=0;
a4=a4+1;
}
if (a4==6)
{a4=0;
a5=a5+1;
}
if (a5==10)
{a5=0;
a6=a6+1;
}
if (a6==2 && a5==4)
{a6=0;
a5=0;
}
Delay_ms(500);}
if (PORTD.F3==0 && PORTD.F2==1) {a5++;
//if (PORTD.F3==0 && PORTD.F2==0){a5++; a3++;}
if (a3==10)
{ a3=0;
a4=a4+1;
}
if (a4==6)
{a4=0;
a5=a5+1;
}
if (a5==10)
{a5=0;
a6=a6+1;
}
if (a6==2 && a5==4)
{a6=0;
a5=0;
}
Delay_ms(500); }
goto restart;
}
else if(PORTD.F0==1 && PORTD.F1==1 && PORTD.F7==0 && PORTD.F6==1)
{
PORTB=e3+e4*16;
PORTC=e5+e6*16;
if (PORTD.F2==0 && PORTD.F3==1) {e3++;
if (e3==10)
{ e3=0;
e4=e4+1;
}
if (e4==6)
{e4=0;
e5=e5+1;
}
if (e5==10)
{e5=0;
e6=e6+1;
}
if (e6==2 && e5==4)
{e6=0;
e5=0;
}
Delay_ms(500);}
if (PORTD.F3==0 && PORTD.F2==1) {e5++;
//if (PORTD.F3==0 && PORTD.F2==0){e5++; e3++;}
if (e3==10)
{ e3=0;
e4=e4+1;
}
if (e4==6)
{e4=0;
e5=e5+1;
}
if (e5==10)
{e5=0;
e6=e6+1;
}
if (e6==2 && e5==4)
{e6=0;
e5=0;
}
Delay_ms(500); }
goto restart;
}
else if(PORTD.F0==1 && PORTD.F1==1 && PORTD.F7==1 && PORTD.F6==0)
{
PORTB=m3+m4*16;
PORTC=m5+m6*16;
if (PORTD.F2==0 && PORTD.F3==1) {m3++;
if (m3==10)
{ m3=0;
m4=m4+1;
}
if (m4==6)
{m4=0;
m5=m5+1;
}
if (m5==10)
{m5=0;
e6=e6+1;
}
if (m6==2 && m5==4)
{m6=0;
m5=0;
}
Delay_ms(500);}
if (PORTD.F3==0 && PORTD.F2==1) {m5++;
//if (PORTD.F3==0 && PORTD.F2==0){e5++; e3++;}
if (m3==10)
{ m3=0;
m4=m4+1;
}
if (m4==6)
{m4=0;
m5=m5+1;
}
if (m5==10)
{m5=0;
m6=m6+1;
}
if (m6==2 && m5==4)
{m6=0;
m5=0;
}
Delay_ms(500); }
goto restart;
}
else if ((PORTD.F0==0 && PORTD.F1==0 && PORTD.F7==0 && PORTD.F6==0 ) || (PORTD.F0==1 && PORTD.F1==1 && PORTD.F7==1 && PORTD.F6==1))
{
PORTA.F0 = 1;
c1++;
PORTB=c3+c4*16;
PORTC=c5+c6*16;
if (c1==10)
{c1=0;
c2=c2+1;
}
if (c2==6)
{c2=0;
c3=c3+1;
}
if (c3==10)
{c3=0;
c4=c4+1;
}
if (c4==6)
{c4=0;
c5=c5+1;
}
if (c5==10)
{c5=0;
c6=c6+=1;
}
if (c6==2 && c5==4)
{c6=0;
c5=0;
}
Delay_ms(7);
PORTA.F0 = 0;
Delay_ms(7);
}
if ((c3==a3+1 && c4==a4 && c5==a5 && c6==a6 ))
{
porta.f1=1;
delay_ms(5000);
c3=c3+1;
}
if ((c3==e3+1 && c4==e4 && c5==e5 && c6==e6 ))
{
porta.f2=1;
delay_ms(5000);
c3=c3+1;
}
if ((c3==m3+1 && c4==m4 && c5==m5 && c6==m6 ))
{
porta.f3=1;
delay_ms(5000);
c3=c3+1;
}
goto restart;
}
please help me..thanks..
i donno how to switch off / reset the LED during the alarm time..in other word: the LED will be on for 2 minute and i need to switch off the LED during that time..
this my code..
int S1, S2, c1, c2, c3, c4, c5, c6, a3, a4, a5, a6, e3, e4, e5, e6, m3, m4, m5, m6 ;
int i;
void main ()
{
PORTA=0;
PORTB=0;
PORTC=0;
TRISA=0;PORTA=0;
TRISB=0;
TRISC=0;
TRISD=255;
PORTD=0;
c1=0; c2=0; c3=0; c4=0; c5=0; c6=0;
a3=0; a4=1; a5=0; a6=0;
e3=0; e4=2; e5=0; e6=0;
m3=0; m4=3; m5=0; m6=0;
restart:
if (PORTD.F0==0 && PORTD.F1==1 && PORTD.F7==1 && PORTD.F6==1)
{
PORTB=c3+c4*16;
PORTC=c5+c6*16;
if (PORTD.F2==0 && PORTD.F3==1) {c3++;
if (c3==10)
{ c3=0;
c4=c4+1;
}
if (c4==6)
{c4=0;
c5=c5+1;
}
if (c5==10)
{c5=0;
c6=c6+1;
}
if (c6==2 && c5==4)
{c6=0;
c5=0;
}
Delay_ms(500);}
if (PORTD.F3==0 && PORTD.F2==1) {c5++;
//if (PORTD.F3==0 && PORTD.F2==0){c5++; c3++;}
if (c3==10)
{ c3=0;
c4=c4+1;
}
if (c4==6)
{c4=0;
c5=c5+1;
}
if (c5==10)
{c5=0;
c6=c6+1;
}
if (c6==2 && c5==4)
{c6=0;
c5=0;
}
Delay_ms(500);}
goto restart;
}
else if(PORTD.F0==1 && PORTD.F1==0 && PORTD.F7==1 && PORTD.F6==1)
{
PORTB=a3+a4*16;
PORTC=a5+a6*16;
if (PORTD.F2==0 && PORTD.F3==1) {a3++;
if (a3==10)
{ a3=0;
a4=a4+1;
}
if (a4==6)
{a4=0;
a5=a5+1;
}
if (a5==10)
{a5=0;
a6=a6+1;
}
if (a6==2 && a5==4)
{a6=0;
a5=0;
}
Delay_ms(500);}
if (PORTD.F3==0 && PORTD.F2==1) {a5++;
//if (PORTD.F3==0 && PORTD.F2==0){a5++; a3++;}
if (a3==10)
{ a3=0;
a4=a4+1;
}
if (a4==6)
{a4=0;
a5=a5+1;
}
if (a5==10)
{a5=0;
a6=a6+1;
}
if (a6==2 && a5==4)
{a6=0;
a5=0;
}
Delay_ms(500); }
goto restart;
}
else if(PORTD.F0==1 && PORTD.F1==1 && PORTD.F7==0 && PORTD.F6==1)
{
PORTB=e3+e4*16;
PORTC=e5+e6*16;
if (PORTD.F2==0 && PORTD.F3==1) {e3++;
if (e3==10)
{ e3=0;
e4=e4+1;
}
if (e4==6)
{e4=0;
e5=e5+1;
}
if (e5==10)
{e5=0;
e6=e6+1;
}
if (e6==2 && e5==4)
{e6=0;
e5=0;
}
Delay_ms(500);}
if (PORTD.F3==0 && PORTD.F2==1) {e5++;
//if (PORTD.F3==0 && PORTD.F2==0){e5++; e3++;}
if (e3==10)
{ e3=0;
e4=e4+1;
}
if (e4==6)
{e4=0;
e5=e5+1;
}
if (e5==10)
{e5=0;
e6=e6+1;
}
if (e6==2 && e5==4)
{e6=0;
e5=0;
}
Delay_ms(500); }
goto restart;
}
else if(PORTD.F0==1 && PORTD.F1==1 && PORTD.F7==1 && PORTD.F6==0)
{
PORTB=m3+m4*16;
PORTC=m5+m6*16;
if (PORTD.F2==0 && PORTD.F3==1) {m3++;
if (m3==10)
{ m3=0;
m4=m4+1;
}
if (m4==6)
{m4=0;
m5=m5+1;
}
if (m5==10)
{m5=0;
e6=e6+1;
}
if (m6==2 && m5==4)
{m6=0;
m5=0;
}
Delay_ms(500);}
if (PORTD.F3==0 && PORTD.F2==1) {m5++;
//if (PORTD.F3==0 && PORTD.F2==0){e5++; e3++;}
if (m3==10)
{ m3=0;
m4=m4+1;
}
if (m4==6)
{m4=0;
m5=m5+1;
}
if (m5==10)
{m5=0;
m6=m6+1;
}
if (m6==2 && m5==4)
{m6=0;
m5=0;
}
Delay_ms(500); }
goto restart;
}
else if ((PORTD.F0==0 && PORTD.F1==0 && PORTD.F7==0 && PORTD.F6==0 ) || (PORTD.F0==1 && PORTD.F1==1 && PORTD.F7==1 && PORTD.F6==1))
{
PORTA.F0 = 1;
c1++;
PORTB=c3+c4*16;
PORTC=c5+c6*16;
if (c1==10)
{c1=0;
c2=c2+1;
}
if (c2==6)
{c2=0;
c3=c3+1;
}
if (c3==10)
{c3=0;
c4=c4+1;
}
if (c4==6)
{c4=0;
c5=c5+1;
}
if (c5==10)
{c5=0;
c6=c6+=1;
}
if (c6==2 && c5==4)
{c6=0;
c5=0;
}
Delay_ms(7);
PORTA.F0 = 0;
Delay_ms(7);
}
if ((c3==a3+1 && c4==a4 && c5==a5 && c6==a6 ))
{
porta.f1=1;
delay_ms(5000);
c3=c3+1;
}
if ((c3==e3+1 && c4==e4 && c5==e5 && c6==e6 ))
{
porta.f2=1;
delay_ms(5000);
c3=c3+1;
}
if ((c3==m3+1 && c4==m4 && c5==m5 && c6==m6 ))
{
porta.f3=1;
delay_ms(5000);
c3=c3+1;
}
goto restart;
}
please help me..thanks..