标题: 数码管动态扫描——(可惜有点错误但现在的我还无法解决) [打印本页]

作者: nius    时间: 2015-4-10 03:11
标题: 数码管动态扫描——(可惜有点错误但现在的我还无法解决)
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar aa,ss,ge,shi,rr;
sbit q1=P2^0;
sbit q2=P2^1;



uchar code shuwei[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

void time(uchar);
void main()
{
ss=13;
P0=0;
P2=0;

rr=0xff;
rr=0;
while(1)
{
shi=ss/10;
ge=ss%10;
P2=0;
P0=shuwei[ge];
P2=0;
q1=1;

time(1);
P2=rr;


P0=shuwei[shi];
P2=0;
q2=1;


time(1);
P2=rr;

}
}
void time(uchar k)
{
uchar x,y;
for(x=100;x>0;x--)
for(y=k;y>0;y--);
}





我控制的位选是P2口中的两个端口但是P2其他口中的其他6个端口都会受其干扰
但如果在实际中不适用其他6个端口也无大碍
不完美的列程所以我还是把他当做以后写程序时的对照吧     当然如果我能用到的话.........

设计者:薛羽豪








欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1