资源描述:
《王耀磊LED点阵显示屏(程序部分)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include#include//要用到_nop_()#defineuintunsignedint#defineucharunsignedcharsbitE1=P3^4;//74HC154(18)-E1为0开列(col)输出显示允许控制信号端口sbitST_CP=P3^2;//74HC595(12)-ST_CP上升沿--移位寄存器的数据进入数据存储寄存器输出锁存器的时钟信号端口sbitMR=P3^3;//74HC595(10)-MR为0将移位寄存器的数据清0uc
2、harcodebmp[]={//字模表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,0xF8,0x0B,0x28,0x09,0x29,0x09,0x2E,0x09,0x2A,0x09,
3、0xF8,0xFF,0x28,0x09,0x2C,0x09,0x2B,0x09,0x2A,0x09,0xF8,0x0B,0x00,0x08,0x00,0x08,0x00,0x00,/*"单",2*/},{0x00,0x80,0x00,0x40,0x00,0x30,0xFE,0x0F,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x10,0x01,0x1F,0x01,0x10,0x01,0x10,0xFF,0x10,0x00,0x18,0x00,0x10,0x00,0x00
4、,0x00,/*"片",3*/},{0x08,0x04,0x08,0x03,0xC8,0x00,0xFF,0xFF,0x48,0x00,0x88,0x41,0x08,0x30,0x00,0x0C,0xFE,0x03,0x02,0x00,0x02,0x00,0x02,0x00,0xFE,0x3F,0x00,0x40,0x00,0x78,0x00,0x00,/*"机",4*/},{0x40,0x00,0x20,0x00,0x10,0x00,0xEC,0x7F,0x07,0x40,0x0A,0x20,0x08,0
5、x18,0x08,0x06,0xF9,0x01,0x8A,0x10,0x8E,0x20,0x88,0x40,0x88,0x20,0xCC,0x1F,0x88,0x00,0x00,0x00,/*"仿",5*/},{0x00,0x10,0x04,0x90,0x04,0x90,0x04,0x50,0xF4,0x5F,0x54,0x35,0x5C,0x15,0x57,0x15,0x54,0x15,0x54,0x35,0x54,0x55,0xF4,0x5F,0x04,0x90,0x06,0x90,0x04,0x10,
6、0x00,0x00,/*"真",6*/};voiddelayXms(ucharms);voidmain(){uintbase=0;//在bmp地址中移动,从0到rows-15,每次加2,实现移动效果ucharcur=0;//显示base位置以后的一个字符宽度,16列,每列16bituinttmp=0;//临时变量uintrows=sizeof(bmp);//"",单,片,机,仿,真共6个字符块,每个16*16,共rows=96列uintcol=0;//列选线SCON=0x00;//串口工作模式0;移位寄存器
7、方式MR=1;while(1){for(base=0;base<=rows;base=base+2){for(tmp=0;tmp<5;tmp++)//每个字块显示5次{for(col=0;col<16;col++){E1=0;//开154移位列MR=0;//清理行输出,将移位寄存器的数据清0MR=1;ST_CP=0;//上升沿ST_CP=1;SBUF=bmp[base+col*2];while(TI==0);//等待发送完毕T1=0;SBUF=bmp[base+col*2+1];while(TI==0);/
8、/等待发送完毕T1=0;P1=0;P1=col;//列控制ST_CP=0;//上升沿ST_CP=1;delayXms(2);//显示2ms}}}}}voiddelayXms(ucharms)//延时毫秒@12M,ms最大值255{uchari;while(ms--)for(i=0;i<130;i++);}