以显示“ | ” 从右向左移为例,第1 屏,右边第1 列亮1ms后灭,第2 屏,第2 列亮。。。。8 屏显示后,完成“| ”左移。
如果是想一起显示四个字母,把所有的led共阴共阳,用单片机做个简单的程序,控制其通断就可以了。如果是想单个显示,则需要把你想显示的单体字母共阴共阳,不过这个程序麻烦点,要控制好几个字母电源通断的时序。当然,如果你c语言过关的话,可以变更复杂的程序,变幻一下闪烁的顺序和频率,效果会更好!题外话:用来追mm不错~
试试如下修改:#include<reg51.h>
unsigned char code tab[] = {0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe}//列选通控制
unsigned char code digittab[9][8] = {
{0x3e,0x41,0x41,0x41,0x3e,0x00,0x00,0x00}, //0 8行,
{0x00,0x3e,0x41,0x41,0x41,0x3e,0x00,0x00},
{0x00,0x00,0x3e,0x41,0x41,0x41,0x3e,0x00},
{0x00,0x00,0x00,0x3e,0x41,0x41,0x41,0x3e},
{0x00,0x00,0x00,0x00,0x3e,0x41,0x41,0x41},
{0x00,0x00,0x00,0x00,0x00,0x3e,0x41,0x41},
{0x00,0x00,0x00,0x00,0x00,0x00,0x3e,0x41},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3e},
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}
unsigned char tt=0
void delay()
{
int m, n
for(m = 20m >0m--) for(n = 15n >0n--)
}
void Disp(unsigned char j)
{
unsigned char i //i定义列,j定义行
for(i = 0i <8i++) {
P0 = digittab[j][i]// 行线
P2 = tab[i]delay()P2 = 0xff// 列线, 扫描时间
}
}
void main(void)
{
unsigned char i, j
while(1) {
for(i = 0i <10i++) Disp(j)
j++
if(j == 9) j = 0
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)