原创 1616点阵

2010-6-5 15:38 2703 5 5 分类: MCU/ 嵌入式
老师给的任务,做一个16×16点阵的LED显示程序,费了一星期,终于鼓捣好了……就顺便发表一下吧……

  本来想使用译码器的,但是始终有些问题,所以就干脆直接用8051的IO口了……5555这不算是成功啊~!  


下面是电路图:


点击看大图


在制作的时候,发现显示的时候,总是会有一部分的LED灯乱闪,也就是乱吗,在网上找了大半天,也没有发现什么比较好的解决办法,后来还是同学给我说了一下别人的程序和我的程序的区别,我才试着去更改程序,后来真的解决了。本来我的显示方式是分别显示完每个8×8点阵,最后把四个拼在一起,可能是这种显示的方法,出现了乱码,后来改为,使用P2口扫描上半部分是,分别给P0和P1送数据,直到显示完上面的八行……然后在显示下边P3口控制的8行。


也就是说,把显示码间隔的送给每个8×8小模块,最后乱码就消失了……我不知道设置了显示缓冲区是否会不会也可以解决这个问题。呵呵,希望会有帮助……


附程序:(低电平点亮)


#include<reg51.h>


#define uchar unsigned char
#define uint unsigned int


uchar code ji[]={
0xFF,0xBF,0xC8,0xEE,0x7F,0x9F,0xDE,0xF1,0xEE,0xDE,0x1E,0xDE,0xDE,0xDD,0xDB,0xDF,
0x7F,0xBB,0x01,0xEF,0x5F,0xBF,0x4F,0xF1,0xEB,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF,0xEF
};


uchar code nan[]={
0xFE,0xFE,0x00,0xFE,0xFE,0x80,0xB7,0xBB,0xA0,0xBE,0xBE,0xA0,0xBE,0xBE,0xBE,0xBF,
0xFF,0xFB,0x01,0xFF,0xFB,0x01,0xDB,0xBB,0x0B,0xFB,0xFB,0x0B,0xFB,0xFB,0xEB,0xF7
};


uchar code zhi1[]={
0xFB,0x01,0xDB,0xDB,0xC3,0xDB,0xDB,0xC3,0xDB,0xDB,0xD8,0x03,0xBB,0xFB,0xFA,0xFB,
0xFF,0xFB,0x01,0x7B,0x7B,0x7B,0x7B,0x7B,0x03,0x7B,0xB7,0xB7,0x7B,0x79,0xFD,0xFF
};


uchar code ye[]={
0xF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xFE,0x00,0xFE,0xFE,0xFE,0xC0,0xFF,0xFD,0xEE,0xAF,0xAF,0x6F,0xF0,0xFF,
0xFF,0xFF,0xFB,0x01,0xFF,0xFF,0xEF,0x07,0xFF,0xFF,0x7F,0x7B,0xED,0xED,0x0F,0xFF
};


uchar code qiang[]={
0xF7,0x02,0xF6,0xF6,0xF6,0x86,0xB7,0xBC,0xBD,0x85,0xF4,0xF5,0xF7,0x77,0xAC,0xDF,
0xFB,0x01,0xFB,0xFB,0x03,0xDB,0xDF,0x01,0xDD,0xDD,0x01,0xDD,0xDF,0xDB,0x01,0xFD
};


uchar code zuo[]={
0xEF,0xED,0xED,0xDD,0xC0,0x9D,0x5D,0xDD,0xD0,0xD7,0xD7,0xD7,0xD7,0xD0,0xD7,0xDF,
0xDF,0xDF,0xDF,0xDB,0x01,0x7B,0xBB,0xBB,0x37,0x57,0x57,0x6F,0x57,0x57,0xB9,0x7B
};


void delay(unsigned char ms)
{
        unsigned int i;
        while(ms--)
        {
         for(i = 0; i<10; i++)
           {  }
        }
}



void disp(unsigned char word[])
{
        uint m;
    for(m=0;m<20;m++)
    {
        unsigned int i;
        P2=0x01;
        for(i=0;i<8;i++)
        {
            P0=word;//显示左边前八行
            P1=word[i+16];//右边的前八行
            delay(5);
            P2<<=1;
        }
        P3=0x01;
        for(i=8;i<16;i++)
        {


            P0=word;//左半边后八行
            P1=word[i+16];//右边后八行
            delay(5);
            P3<<=1;
        }
    }


}


void main()
{
    delay(500);
    while(1)
    {
   
    disp(ji);//济
    disp(nan);//南
    disp(zhi1);//职
    disp(ye);//业
    disp(xue);//学
    disp(yuan);//院
    disp(dian);//电
    disp(zi);//子
    disp(gong);//工
    disp(cheng);//程
    disp(xi);//系
    disp(dian);//电
    disp(qi);//气
    disp(er);//二
    disp(ban);//班
    disp(zhu);//朱
    disp(zhi2);//志
    disp(qiang);//强
    disp(zuo); // 做 
    }
}


时间:2009.12

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
5
关闭 站长推荐上一条 /3 下一条