case
void two() ;
void five() ;
void tree() ;
void four() ;
void one() ;
void six() ;
void seven() ;
void eigth() ;
void nine() ;
void main()
{
int i=0;
TRISB = 0x00;
TRISA.F0 =0 ;
TRISA.F1 =0 ;
TRISA.F2 =0 ;
TRISA.F3 =0 ;
PORTB = 0;
while (1)
{
if (PORTA.F0==1) {i=i+1;}
if (PORTA.F1==1) {i=i+2;}
if (PORTA.F2==1) {i=i+3;}
if (PORTA.F3==1) {i=i+4;}
switch (i) {
case 1:
one()=1;
two();
i=0;
break;
case 2:
tree()=1;
four()=1;
i=0;
break;
case 3:
five()=1;
six()=1;
i=0;
break;
case 4:
seven()=1;
eigth() =1;
nine() =1;
i=0;
break;
}
}
}
void two()
{
PORTB = 0x5B;
Delay_ms(500);
PORTB = 0;
Delay_ms(500);
}
void five()
{
PORTB = 0x6D;
Delay_ms(500);
PORTB = 0;
Delay_ms(500);
}
void tree()
{
PORTB = 0x4F;
Delay_ms(500);
PORTB = 0;
Delay_ms(500);
}
void four()
{
PORTB = 0x66;
Delay_ms(500);
PORTB = 0;
Delay_ms(500);
}
void one()
{
PORTB = 0x06;
Delay_ms(500);
PORTB = 0;
Delay_ms(500);
}
void six()
{
PORTB = 0x7D;
Delay_ms(500);
PORTB = 0;
Delay_ms(500);
}
void seven()
{
PORTB = 0x07;
Delay_ms(500);
PORTB = 0;
Delay_ms(500);
}
void eigth()
{
PORTB = 0xFF;
Delay_ms(500);
PORTB = 0;
Delay_ms(500);
}
void nine()
{
PORTB = 0x6F;
Delay_ms(500);
PORTB = 0;
Delay_ms(500);
}

ความคิดเห็น
แสดงความคิดเห็น