源程序如下:
#include<reg52.h>
//端口定义
sbit hhp = P2^0; //行输出移位允许
sbit hds = P2^1; //行数据输入
sbit htp = P2^2; //行输出锁存
sbit lhp = P2^3; //列输出移位
sbit lds = P2^4; //列数据输入
sbit ltp = P2^5; //列输出锁存
unsigned int code zhong[]=
{
0xFF,0xFF,0xF0,0xF7,0xF7,0xF7,0xF7,0x00,0xF7,0xF7,0xF7,0xF7,0xF0,0xFF,0xFF,0xFF,
0xFF,0xFF,0x0F,0xDF,0xDF,0xDF,0xDF,0x00,0xDF,0xDF,0xDF,0xDF,0x0F,0xFF,0xFF,0xFF
};
//延时函数1ms
void delay(unsigned int t)
{
unsigned int x,y;
for(x=t;x>0;x--)
for(y=110;y>0;y--)
;
}
//行输出
void hang(unsigned int w)
{
unsigned int z;
for(z=0;z<8;z++)
{
hhp = 0;
w = w<<1;
hds = CY;
hhp = 1;
delay(1);
}
htp = 0;
delay(1);
htp = 1;
delay(1);
htp = 0;
}
//输出到led点阵
void display(void)
{
unsigned int i,j,temp,tmp;
tmp = 0x80;
for(i=0;i<16;i++)
{
lhp = 0;
tmp = tmp<<1;
lds = CY;
lhp = 1;
delay(1);
ltp = 0;
delay(1);
ltp = 1;
delay(1);
for(j=0;j<2;j++)
{
temp = zhong[i*2+j];
hang(temp);
}
}
}
void main (void)
{
P2 = 0x00;
while(1)
{
display();
}
}
为什么行没有输出啊,就是void hang(unsigned int w)这个函数里面的hds压根没有输出?求大神解答
-
电路原理图
-
-
16点阵测试.zip
下载积分: 积分 -1 分
45.92 KB, 下载次数: 8, 下载积分: 积分 -1 分
一周热门 更多>