switch.c(35): error C231: 'plus': redefinition switch.c(45): error C231: 'plus':
#include<reg51.h>#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
uchar code seg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};//¹²ÑôLEDÊýÂë¹Ü¶ÎÂë±í
void delay(uint t) //ÑÓʱº¯Êý
{
uchar j;
while(t --)
for(j=0;j<200;j++);
}
void main() //Ö÷º¯Êý
{
do
{
char state;
P1=0xff;//p1ΪÊäÈë¿Ú
state=P1;//¶Áp1µÄ״̬ËÍÈëstate
state=state&0x03;//ÆÁ±ÎP1¿Ú¸ß6λµÄ״̬
switch(state)//ÅжÏp1¿ÚµÍÁ½Î»µÄ״̬
{
case 0:keep();
break;
case 1:plus();
break;
case 2:minus();
break;
case 3:keep();
break;
}
}
while(1);
}
void plus(void) //ÕýÏòÑ­»·º¯Êý
{
uchar i;
while(1)
{
for(i=0;i<9;i++)
{
P0=seg[i];
delay(900);
}
}
}
void minus(void) //·´ÏòÑ­»·º¯Êý
{
uchar i;
while(1)
{
for(i=9;i>0;i--)
{
P2=seg[i];
delay(900);
}
}
}