#include"reg51.h"
#define uchar unsigned char
uchar display_code[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,
0x7d,0x07,0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar display_data[8]={0,0,0,0,0,0,0,0};
void delay()
{
uchar i;
for(i=250;i>0;i--);
}
void display()
{
uchar z,k;
k=0x80;
for(z=0;z<8;z++)
{
P2=0;
P0=display_code[display_data[z]];
P2=k;
k=k>>1;
delay();
}
P2=0;
}
void calc()
{
display_data[7]++;
if(display_data[7]>9)
{
display_data[7]=0;
display_data[6]++;
if(display[6]>9)
{
display_data[6]=0;
}
}
}
void main()
{
uchar a;
while(1)
{
for(a=0;a<250;a++)
{
display();
}
calc();
}
}
这是我从一本书上抄写下来的0~99累加计数小程序,变编译的时候报错(静态事牍?c(35): error C216: subscript on non-array or too many dimensions),恳请大神们帮忙看看是这么不对呢
|