Build target '目標(biāo) 1'
compiling 十花樣.c...
十花樣.C(94): error C141: syntax error near 'if'
十花樣.C(94): error C141: syntax error near '==', expected ')'
十花樣.C(94): error C129: missing ';' before '=='
目標(biāo)未創(chuàng)建
單片機(jī)源程序如下:
#include<reg51.h>
#define false 0
#define true 1
#define uchar unsigned char
#define uint unsigned int
sbit pause_key=P3^0;
sbit auto_key=P3^1;
sbit change_key=P3^2;
sbit pauseLed=P3^6;
sbit autoLed=P3^7;
int ledCode[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f} ;
int ledCode2[8]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00} ;
int disCode[10]={0x03,0x9f,0x25,0x0d,0x99,0x49,0x41,0x1f,0x01,0x09} ;
void displayLed(void);
void keyScan(void) ;
void Delay10ms( unsigned int n);
bit isPause=false;
bit isAuto=true;
bit isChange=false;
uchar time;
uchar types;
uchar counts;
void T0_INT(void) interrupt 1
{
TL0=(65536-50000)/256;
TH0=(65536-50000)%256;
time++;
if(time>=10)
{
time=0;
if(isChange==true)
{
counts=0;
types++;
if(types>9)types=0;
P0=disCode[types] ;
isChange=false;
}
displayLed();
counts++;
}
}
void main(void)
{
TMOD=0x61;
TL0=(65536-50000)/256;
TH0=(65536-50000)%256;
TR0=1;
ET0=1;
EA=1;
time=0;
counts=0;
types=0;
pauseLed=0;
P0=disCode[types] ;
while(1)
{
keyScan();
}
}
void keyScan(void)
{
if(pause_key==0)
{
Delay10ms(1);
if(pause_key==0)
{
isPause=~isPause;
pauseLed=isPause ;
if(isPause==true)
{
ET0=0;
P0=0xfd;
P1=0x00;
P2=0x00;
}
else
{
ET0=1;
P0=disCode[types];
displayLed();
}
while(pause_key==0);
}
}
if(auto_key==0)
{
isAuto=~isAuto;
autoLed=isAuto;
}
while(auto_key==0);
}
if(change_key==0&&isAuto==false)
{
Delay10ms(1);
if(change_key==0)
{
isChange=true;
}
while (change_key==0);
}
void displayLed(void)
{
switch(types)
{
case:0
{
if(counts>=16)counts=0;
if(counts>=15)
{
if(isAuto==true) isChange=true;
}
if(counts<8)
{
P1=0xff;
P2=ledCode[7-counts];
}
else
{
P1=ledCode[15-counts];
P2=0xff;
}
break;
}
case 1:
{
if(counts>=16)counts=0;
if(counts>=15)
{
if(isAuto==true)isChange=true;
}
if(counts<8)
{
P1=ledCode[counts];
P2=0xff;
}
else
{
P1=0xff;
P2=ledCode[counts-8];
}
break;
}
case 2:
{
if(counts>=16)counts=0;
if(counts>=15)
{
if(isAuto==true) isChange=true;
}
if(counts%2==0)
{
P1=0xaa;
P2=0xaa;
}
else
{
P1=0x55;
P2=0x55;
}
break;
}
case 3:
{
if(counts>=8)counts=0;
if(counts>=7)
{
if(isAuto==true)isChange=true;
}
P1=ledCode[7-counts];
P2=ledCode[7-counts];
break;
}
case 4:
{
if(counts>=8)counts=0;
if(counts>=7)
{
if(isAuto==true)isChange=true;
}
P1=ledCode[counts];
P2=ledCode[counts];
break;
}
case 5:
{
if(counts>=17)counts=0;
if(counts<8)
{
P1=~ledCode2[7-counts];
P2=0xff;
}
else if(counts<16)
{
P1=0x00;
P2=~ledCode2[15-counts];
}
else
{
P1=0x00;
P2=0x00;
if(isAuto==true)isChange=true;
}
break;
}
case 6:
{
if(counts>=17)counts=0;
if(counts<8)
{
P1=ledCode2[7-counts];
P2=0x00;
}
else if(counts<16)
{
P1=0xff;
P2=ledCode2[15-counts];
}
else
{
P1=0xff;
P2=0xff;
if(isAuto==true)isChange=true;
}
break;
}
case 7:
{
if(counts>=17)counts=0;
if(counts<8)
{
P1=0xff;
P2=ledCode2[counts];
}
else if(counts<16)
{
P1=ledCode2[counts-7];
P2=0x00;
}
else
{
P1=0x00;
P2=0x00;
if(isAuto==true)isChange=true;
}
break;
}
case 8:
{
if(counts>=17)counts=0;
if(counts<8)
{
P1=0x00;
P2=~ledCode2[counts];
}
else if(counts<16)
{
P1=~ledCode2[counts-7];
P2=0xff;
}
else
{
P1=0xff;
P2=0xff;
if(isAuto==true)isChange=true;
}
break;
}
case 9:
{
if(counts>=255)counts=0;
if(counts==254&&isAuto==true)
isChange=true;
P1= ~counts;
P2= ~counts;
break;
}
default:
types=0;
P0=disCode[types];
}
}
void Delay10ms( unsigned int n)
{
unsigned char a,b;
for(;n>0;n--)
{
for(b=38;b>0;b--)
{
for(a=130;a>0;a--);
}
}
}
|