四个点阵发现做列驱动时候,有些引脚没有电位变化,似乎没有控制到……希望各位高手指点指点……
程序如下,希望各位多帮帮忙,指出错误……
#include<reg52.h>
#include<intrins.h>
sbit RCKH = P2^0;
sbit SDAH = P2^2;
sbit SCKH = P2^1;
sbit SCKL = P2^4;
sbit SDAL = P2^5;
sbit RCKL = P2^3;
unsigned char hang[16]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01,0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01},
lie[32]={0xFF,0xFF,0xE0,0x0F,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xE0,0x0F,
0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xE0,0x0F,0xFF,0xFF
};
wrh_595(unsigned char numh )
{
unsigned char counth;
for(counth=0;counth<=7;counth++)
{
SCKH = 0;
if((numh&0x80) == 0x80)
SDAH = 1;
else
SDAH = 0;
numh<<=1;
SCKH = 1;
}
}
wrl_595(unsigned char numl )
{
unsigned char countl;
for(countl=0;countl<=7;countl++)
{
SCKL = 0;
if((numl&0x80) == 0x80)
SDAL = 1;
else
SDAL = 0;
numl<<=1;
SCKL = 1;
}
}
void main()
{
unsigned char t,j;
while(1)
{
t=0;j=0;
while(t<=7)
{
RCKL = 0;
wrl_595(lie[j++]);
wrl_595(lie[j++]);
RCKL = 1;
RCKH = 0;
wrh_595(hang[t++]);
wrh_595(0x00);
RCKH = 1;
}
while(t<=15)
{
RCKL = 0;
wrl_595(lie[j++]);
wrl_595(lie[j++]);
RCKL = 1;
RCKH = 0;
wrh_595(0x00);
wrh_595(hang[t++]);
RCKH = 1;
}
}
}
-
两个做行驱动,两个做列驱动
-
单片机
-
点阵
一周热门 更多>