汉字LED点阵16X16滚动显示设计
#include <reg52.h> #define int8 unsigned char #define int16 unsigned int #define int32 unsigned long int8 flag; int8 n; int8 code table[][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},/* " " */ {0x04,0x28,0x08,0x24,0x32,0x22,0xC2,0x21,0xC2,0x26,0x34,0x38,0x04,0x04,0x08,0x18,0x30,0xF0,0xC0,0x17,
0x60,0x10,0x18,0x10,0x0C, 0x14,0x06,0x18,0x04,0x10,0x00,0x00},/*"欢",0*/
{0x02,0x02,0x04,0x82,0xF8,0x73,0x04,0x20,0x02,0x00,0xE2,0x3F,0x42,0x20,0x82,0x40,0x02,0x40,0xFA, 0x3F,0x02,0x20,0x42,0x20,0x22,0x20,0xC2,0x3F,0x02,0x00,0x00,0x00},/*"迎",1*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0
0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}/* " " */ }; void delay(void); int16 offset; void main(void) { int8 i; int8 *p; flag=0x10; n=0; TMOD=0x01; TH0=0xb1; TL0=0xe0; ET0=1; EA=1; TR0=1; p=&table[0][0]; while (1) { for (i=0;i<8;i++) //显示左半边屏幕 { P0=*(p+offset+2*i); P2=i|0x08; //P2.4=0,P2.3=1 选中U2, 输出扫描码给U6 delay(); P0=*(p+offset+2*i+1); P2=i|0x10; //P2.4=1,P2.3=0 选中U3, 输出扫描码给U7 delay(); } for (i=8;i<16;i++)
//显示右半边屏幕 { P0=*(p+offset+2*i); P2=(i-8)|0x20; //P2.5=1 P2.4=0, P2.3=0 选中U4,输出扫描码U8 delay(); P0=*(p+offset+2*i+1); P2=(i-8)|0x40; //P2.6=1 P2.5=0, P2.4=0 选中U5,输出扫描码U9 delay(); } } } void delay(void) { int16 i; for (i=0;i<50;i++) ; } void timer0() interrupt 1 using 3 { TF0=0; TH0=0xb1; TL0=0xe0; if (n<10) { n++; } else { offset+=2; if (offset>1100) offset=0; n=0; } }
<h2>Project:</h2>
C:\Documents and Settings\Administrator\桌面\16×16点阵(滚动显示)\16×16点阵(滚动显示)\16×16点阵.uv2
Project File Date: 11/17/2006
<h2>Output:</h2>
这个中断是为了产生offset的原理是什么,为什么能实现汉字的移动显示(从右至左)
{0x04,0x28,0x08,0x24,0x32,0x22,0xC2,0x21,0xC2,0x26,0x34,0x38,0x04,0x04,0x08,0x18,0x30,
0xF0,0xC0,0x17,0x60,0x10,0x18,0x10,0x0C, 0x14,0x06,0x18,0x04,0x10,0x00,0x00},/*"欢",0*/
需要源程序的找站长1066