#include
#include #define uint unsigned int #define uchar unsigned char #define BLKN 2 /*列存贮器数,表示8*8led组合的行数*/ sbit E1 =P3^4; //74HC154(18)-E1 为0开列(col)输出 显示允许控制信号端口 sbit ST_CP =P3^2; //74HC595(12)-ST_CP 上升沿--移位寄存器的数据进入数据存储寄存器 输出锁存器的时钟信号端口 sbit MR =P3^3; //74HC595(10)-MR 为0将移位寄存器的数据清0 void delay(unsigned int); //延时函数 uchar data dispram[32]; //显示缓存 uchar code bmp[][32]={ //字模表 //{ //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,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,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,0x18,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,0x00,0x00,/*"真",6*/ } }; void main( ) { uchar num,cur,tmp,nums=sizeof(bmp)/32; //num:当前显示的文字块指针 //cur:当前文字块的断码指针(bmp) //tmp:临时变量 //nums:总文字块数 SCON = 0x00; //串口工作模式0;移位寄存器方式 TMOD = 0x01; //定时器T0工作方式1:16位方式 TR0 = 1; //T1 P1 = 0x3f; // IE = 0x82; //中断允许设置 while (1) { delay(1000); //2种效果之间的停顿 // for(tmp=0;tmp<1;tmp++) //让卷动效果只显示一次 { //delay(2000); //延时2s 一条标语滚动一次前的延时时间 delay(100); for(num=0;num for(cur=0;cur<32;cur++) //显示效果:卷帘出 { dispram[cur]=bmp[num][cur]; if((cur % 2)==1) delay(100); } delay(100); } } delay(1000); //2种效果之间的停顿 // for(tmp=0;tmp<1;tmp++) //让卷动效果只显示一次 { //delay(2000); //延时2s 一条标语滚动一次前的延时时间 delay(100); for(num=0;num for(cur=31;cur<0xff;cur--)//显示效果:卷帘入 当cur为0时,再循环一次就为0xff { dispram[cur]=bmp[num][cur]; if((cur % 2)==0) delay(100); } delay(100); } } } } ///////延时函数 void delay(uint dt) { uchar bt; for(;dt;dt--) for(bt=0;bt<255;bt++); } //////////显示屏扫描(定时器T0中断)函数 void leddisplay(void) interrupt 1 using 1 { static uchar col=0; TH0 = 0xF8; //设定显示屏刷新率62.5帧/S TL0 = 0x30; MR=0; //清理行输出,将移位寄存器的数据清0 MR=1; SBUF = dispram[col*2]; //送显示数据 while(TI==0); //等待发送完毕 T1 = 0; SBUF = dispram[col*2+1]; //送显示数据 while(TI==0); //等待发送完毕 T1 = 0; E1 = 1; //消隐(关闭显示) P1 = 0xF0; //行号端口清0 多余2行,但是去掉后不行 P1 = 0xF0; //行号端口清0 E1 = 0; //打开显示 ST_CP =1; //显示数据打入输出锁存器 ST_CP = 0; //锁存显示数据 P1 = col; //写入行号 col=(col+1)%16; }
相关文章