第1个回答 2013-07-10
#include <reg51.h>
unsigned char code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void show();
void delay();
void main()
{
while(1)
show();
}
void show()
{
unsigned char i;
for(i=0;i<8;++i)
{
P0=table[i+1];
P2=~(0x01<<i);
delay();
P2=0xFF;
}
}
void delay()
{
int i=100;
while(i--);
}来自:求助得到的回答本回答被提问者采纳
第1个回答 2013-07-10
#include"reg52.h"
#define uchar unsigned char
#define uint unsigned int
sbit dula=P2^6;
sbit wela=P2^7;
uchar aa;
uchar code table[]={0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
void delay(uint x)
{uint i,j;
for(i=x;i>0;i--)
for(j=110;j>0;j--);}
void main()
{int num;
while(1)
{
num=0;aa=0xfe;
for(;num<8;num++)
{
dula=1;
P0=table[num];
dula=0;
P0=aa;
wela=1;
P0=0xfe;
wela=0;
aa=_cror_(aa,1);
delay(500);
}
}
}
}
追问好像有错误,你在检查检查
追答对不起啊,当时没有看到你的原理图!