#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個端口也無大礙
不完美的列程所以我還是把他當做以后寫程序時的對照吧 當然如果我能用到的話.........
設計者:薛羽豪
|