该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
sbit cs1=P2^0;
sbit cs2=P2^1;
sbit wr=P2^2;
unsigned char ss[8]={0,1,2,3,4,5,6,7}; //段 选 择
unsigned char code dxk[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x89,0x8c,0xbf,0xff}; //段 选 库
unsigned char code wxk[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; //位 选 库
unsigned char x=0;
void ys(unsigned int i)
{
while(i>0)i--;
}
void dx()
{
wr=0;
cs1=0;
wr=1;
cs1=1;
}
void wx()
{
wr=0;
cs2=0;
wr=1;
cs2=1;
}
void xs()
{
while(x<8)
{
P0=dxk[ss[x]];
dx();
P0=wxk[x];
wx();
ys(10);
P0=0xff;
wx();
x++;
}x=0;
}
void main()
{
while(1)
{
ss[0]=1;
ss[1]=1;
ss[2]=1;
ss[3]=18;
ss[4]=6;
ss[5]=5;
ss[6]=7;
ss[7]=0;
xs();
}
}
这是一个让数码管以流水灯的形式显示0756-111的程序。但是老师没有和我们讲
void dx()
{
wr=0;
cs1=0;
wr=1;
cs1=1;
}
void wx()
{
wr=0;
cs2=0;
wr=1;
cs2=1;
}
这两个定义里面是什么意思,让我们先按照这个格式写,以后再告诉我们这是什么意思。所以我只能来贴吧先问问 - -
只知道这两个定义的功能,一个是用来显示数字,一个是用来选择控制数码管的。但是不知道为什么要这样写。