程序简单,适合初学者,内附原理图代码等,用proteus8制作,用16*16点阵显示汉字。
proteus8仿真原理图:
单片机源程序如下:
- #include<reg51.h>
- #include<stdlib.h>
- #define uchar unsigned char
- #define uint unsigned int
- uchar code col[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};//列控制数组
- uchar code row[][32]={ //字模
- {0x40,0x00,0x80,0x00,0xFE,0x7F,0x02,0x40,0x81,0x20,0x80,0x00,0x80,0x00,0xFE,0x3F,
- 0xC0,0x01,0xA0,0x02,0x90,0x04,0x88,0x08,0x84,0x10,0x83,0x60,0x80,0x00,0x80,0x00},/*"宋",0*/
- {0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFF,0x7F,0x80,0x00,
- 0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0xFC,0x1F,0x00,0x00},/*"士",0*/
-
- {0x20,0x04,0x20,0x08,0x20,0x08,0x20,0x00,0xFF,0x7F,0x20,0x01,0x20,0x11,0x20,0x11,
- 0x20,0x09,0x10,0x05,0x10,0x03,0x08,0x41,0x88,0x41,0x44,0x41,0x22,0x7E,0x01,0x00},/*"龙",0*/
- {0x20,0x00,0x70,0x00,0x1E,0x00,0x10,0x3E,0x10,0x22,0xFF,0x22,0x10,0x22,0x18,0x22,
- 0x38,0x22,0x54,0x22,0x54,0x22,0x12,0x22,0x11,0x3E,0x10,0x22,0x10,0x00,0x10,0x00},/*"和",0*/
- {0x08,0x00,0x10,0x3E,0xFF,0x22,0x00,0x12,0x7E,0x12,0x42,0x0A,0x7E,0x12,0x00,0x12,
- 0x7E,0x22,0x20,0x22,0x10,0x22,0xF0,0x16,0x1F,0x0A,0x10,0x02,0x14,0x02,0x08,0x02},/*"郭",0*/
- {0x08,0x02,0x08,0x02,0xFC,0x7E,0x14,0x09,0xA2,0x10,0x01,0x0F,0xFC,0x00,0x80,0x00,
- 0x80,0x00,0xFF,0x7F,0x80,0x00,0x40,0x01,0x20,0x02,0x10,0x04,0x0C,0x18,0x03,0x60},/*"笑",0*/
-
- {0x08,0x02,0x08,0x02,0xFC,0x7E,0x14,0x09,0xA2,0x10,0x01,0x0F,0xFC,0x00,0x80,0x00,
- 0x80,0x00,0xFF,0x7F,0x80,0x00,0x40,0x01,0x20,0x02,0x10,0x04,0x0C,0x18,0x03,0x60},/*"笑",0*/
- {0x20,0x20,0x24,0x20,0x24,0x20,0xFC,0x25,0x22,0x24,0x20,0x24,0xFF,0x27,0x20,0x24,
- 0x20,0x24,0xFC,0x25,0x24,0x25,0x24,0x25,0x64,0x21,0xA4,0x20,0x20,0x28,0x20,0x10},/*"制",0*/
- {0x90,0x00,0x90,0x00,0x90,0x00,0x88,0x7F,0x48,0x01,0x4C,0x01,0x2C,0x01,0x0A,0x1F,
- 0x09,0x01,0x08,0x01,0x08,0x01,0x08,0x3F,0x08,0x01,0x08,0x01,0x08,0x01,0x08,0x01},/*"作",0*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x00,0x0C,0x00,0x08,0x00,0x04,0x00,0x00,0x00},/*",",0*/
- {0x80,0x10,0x42,0x10,0xE4,0x11,0x24,0x11,0xE0,0x7D,0x20,0x11,0xE7,0x11,0x24,0x13,
- 0x24,0x15,0xF4,0x15,0x84,0x11,0x54,0x11,0x2C,0x11,0x14,0x11,0x40,0x15,0x80,0x08},/*"谢",0*/
- {0x80,0x10,0x42,0x10,0xE4,0x11,0x24,0x11,0xE0,0x7D,0x20,0x11,0xE7,0x11,0x24,0x13,
- 0x24,0x15,0xF4,0x15,0x84,0x11,0x54,0x11,0x2C,0x11,0x14,0x11,0x40,0x15,0x80,0x08},/*"谢",0*/
- {0x00,0x00,0x80,0x3F,0x80,0x20,0xBF,0x20,0xA0,0x24,0xA0,0x24,0x92,0x24,0x94,0x24,
- 0x88,0x24,0x88,0x2A,0x14,0x0A,0x24,0x09,0x22,0x09,0x81,0x48,0x40,0x48,0x20,0x70},/*"观",0*/
- {0x00,0x1F,0xFE,0x00,0x80,0x00,0xFC,0x1F,0x40,0x00,0xFF,0x7F,0x20,0x00,0x10,0x00 ,
- 0xF8,0x0F,0x14,0x08,0xF2,0x0F,0x11,0x08,0xF0,0x0F,0x10,0x08,0xF0,0x0F,0x10,0x08},/*"看",0*/
- {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x18,0x00,0x24,0x00,0x24,0x00,0x18,0x00,0x00,0x00,0x00,0x00},/*"。",0*/
- };
-
- void delayms(uint t) //延时函数
- {
- uint x,y;
- for(x=t;x>0;x--)
- for(y=124;y>0;y--);
- }
- void display(uint n) //显示函数
- {
- uint i,j;
- for(j=0;j<12;j++)
- for(i=0;i<16;i++)
- {
- P2=col[i];
- P0=row[n][2*i];
- P1=row[n][2*i+1];
- delayms(3);
- }
- }
- void main() //主函数
- {
- P3=0;
- while(1)
- {
- P3=0;if(P3!=0){display(0);delayms(50);}else break;
- P3=0;if(P3!=0){display(1);delayms(50);}else break;
- P3=0;if(P3!=0){display(2);delayms(50);}else break;
- P3=0;if(P3!=0){display(3);delayms(50);}else break;
- P3=0;if(P3!=0){display(4);delayms(50);}else break;
- P3=0;if(P3!=0){display(5);delayms(50);}else break;
- P3=0;if(P3!=0){display(6);delayms(50);}else break;
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
led胸牌.rar
(22.27 KB, 下载次数: 78)
|