玩电子 > PLC技术
+

51单片机点阵显示汉字C语言程序

2020-05-07    作者:未知    来源:网络文摘

#include

#include

#define uint unsigned int

#define uchar unsigned char


sbit SH_595=P2^1;

sbit DATA_595=P2^0;

sbit ST_CP_595=P2^2;//74HC595(12)-ST_CP上升沿-移位寄存器的数据进入数据存储寄存器 输出锁存器的时钟信号端口

sbit MR_595=P2^3; //74HC595(10)-MR 为0将移位寄存器的数据清0

sbit E1_154=P2^4;//74HC154(18)-E1为0开列(col)输出 显示允许   控制信号端口

    

uchar keynum;

uchar tempbmp[64];



uint base=0;  //在bmp地址中移动,从0 到 rows - 15,每次加2,实现移动效果

uint tmp=0;        

uint col=0;        


unsigned char code bmp1[]={    //字模表



0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,



0x00,0x08,0x00,0x08,0x1F,0xC8,0x92,0x48,0x52,0x48,0x32,0x48,0x12,0x48,0x1F,0xFF,

0x12,0x48,0x32,0x48,0x52,0x48,0x92,0x48,0x1F,0xC8,0x00,0x08,0x00,0x08,0x00,0x00,/*"单",0*/


0x00,0x00,0x00,0x01,0x00,0x06,0x7F,0xF8,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,

0x04,0x40,0xFC,0x40,0x04,0x7F,0x04,0x00,0x04,0x00,0x04,0x00,0x00,0x00,0x00,0x00,/*"片",1*/


0x08,0x20,0x08,0xC0,0x0B,0x00,0xFF,0xFF,0x09,0x00,0x08,0xC1,0x00,0x06,0x7F,0xF8,

0x40,0x00,0x40,0x00,0x40,0x00,0x7F,0xFC,0x00,0x02,0x00,0x02,0x00,0x1E,0x00,0x00,/*"机",2*/


0x02,0x00,0x02,0x00,0x42,0x00,0x33,0xFC,0x00,0x09,0x02,0x11,0x05,0x02,0x79,0xC2,

0x41,0x34,0x41,0x08,0x41,0x14,0x79,0x62,0x05,0x82,0x04,0x01,0x04,0x01,0x00,0x00,/*"设",3*/


0x02,0x00,0x02,0x00,0x42,0x00,0x33,0xFE,0x00,0x04,0x02,0x08,0x02,0x00,0x02,0x00,

0x02,0x00,0xFF,0xFF,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x02,0x00,0x00,0x00,/*"计",4*/


0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,


0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,



};


void delayXms(uchar ms)               // 延时毫秒@12M,ms最大值255   

{   

    uchar i;   

    while(ms--)   

        for(i = 0;i<10;i++);    

}

void SendByte(uchar a) // 

{

    uchar byte,i;

    byte=a;

    for(i=0;i<8;i++)

    {

        SH_595=0;

        if(byte&0X80)

            DATA_595=1;

        else

            DATA_595=0;

        SH_595=1;

        byte<<=1;

    }

}

void sendbmp(uchar *bmp,uint rows)

{


        for(base=0;base<=rows-64;base=base+2)// 左移动

         {

             for(tmp=0;tmp<5;tmp++) //每个字块显示5次

             {

                for(col=0;col<16;col++)

                {

                    E1_154=0;                   //为0,允许显示

                    MR_595=0;                //清理行输出,将移位寄存器的数据清0

                    MR_595=1;

                    ST_CP_595=0;            //上升沿

                    ST_CP_595=1;    

                //    base=64;            

                    SendByte(bmp[base+col*2]);        // 实际上595是输出    行数据分为第一个&上半屏,下半屏 第二个字上下半屏

                    SendByte(bmp[base+col*2+1]);


                     P1=col;                //列控制

                    ST_CP_595=0;        //上升沿

                    ST_CP_595=1;                    

                    delayXms(7);        //显示2ms

                }

        }

    }

}


void main()

{

        //列选线

     MR_595=1;

      E1_154=1;



    while(1)

    {

         sendbmp(&bmp1,sizeof(bmp1));//显示第2次字

    }

}

阅读:613    评论:0
  • 相关文章
  • 热门文章
网站地图

免责申明:我要玩起网旨在提供一个相互学习交流的平台,是一个完全免费的网站,部分原创作品,欢迎转载,部分内容来自互联网,如果侵犯了您的权利请尽快通知我们!邮箱:279459762@qq.com Copyright 2018-2021我要玩起网

湘ICP备17006802号-2
【电脑版】  【回到顶部】