main.c(参考了好多大神的源码,结合矩阵键盘和LCD12864,显示相应的数字)
- #include<AT89X52.h>
- #include"12864.h"
- #define uchar unsigned char
- #define uint unsigned int
- uchar code dazi[9][64]=
- {
- { //1
- 0x00,0x10,0x10,0x10,0x18,0x38,0xFC,0xFE,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x40,0x40,0x40,0x60,0x70,0x7F,0x7F,0x7F,0x70,0x60,0x40,0x40,0x40,0x00,0x00,
- },
- {//2
- 0x00,0xE0,0xF8,0xFC,0x8C,0x06,0x06,0x02,0x02,0x06,0x0E,0x1E,0xFC,0xF8,0xF0,0x00,
- 0x00,0x07,0x07,0x07,0x07,0x00,0x00,0x00,0x00,0x00,0xC0,0xF8,0xFF,0x7F,0x1F,0x00,
- 0x00,0x00,0x00,0x80,0xC0,0xE0,0x70,0x3C,0x1E,0x0F,0x03,0x01,0x00,0x00,0x80,0x80,
- 0x70,0x7C,0x7E,0x77,0x73,0x70,0x70,0x70,0x70,0x70,0x70,0x70,0x78,0x7E,0x7F,0x01,
- },
- {//3
- 0x00,0xF0,0xF8,0xFC,0xCE,0x06,0x02,0x02,0x06,0x06,0x1E,0xFC,0xF8,0xF0,0xC0,0x00,
- 0x00,0x01,0x01,0x01,0x01,0x00,0x80,0x80,0xC0,0xE0,0xF0,0x7F,0x3F,0x1F,0x03,0x00,
- 0x00,0x80,0x80,0x80,0x80,0x00,0x00,0x00,0x01,0x01,0x03,0x07,0xFF,0xFE,0xF8,0xE0,
- 0x00,0x0F,0x1F,0x3F,0x77,0x60,0x40,0x40,0x40,0x60,0x70,0x38,0x3F,0x1F,0x0F,0x01,
- },
- {//4
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xF0,0xF8,0xFE,0xFF,0xFE,0x00,0x00,0x00,
- 0x00,0x00,0x00,0xC0,0xF0,0x7C,0x1F,0x07,0x01,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
- 0x70,0x7C,0x7F,0x77,0x71,0x70,0x70,0x70,0x70,0xFF,0xFF,0xFF,0xFF,0x70,0x70,0x70,
- 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xC0,0xC0,0xFF,0xFF,0xFF,0xFF,0xE0,0xC0,0xC0,
- },
- {//5
- 0x00,0x00,0xFE,0xFE,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x06,0x00,
- 0x00,0x00,0xFF,0xFF,0xE0,0x70,0x70,0x30,0x30,0x70,0x70,0xF0,0xE0,0xC0,0x80,0x00,
- 0x00,0xC0,0xC3,0xC3,0xC1,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFC,
- 0x00,0x0F,0x1F,0x3F,0x73,0x60,0x60,0x40,0x40,0x60,0x70,0x78,0x3F,0x1F,0x07,0x00,
- },
- {//6
- 0x00,0x00,0xE0,0xF0,0xF8,0x1C,0x0E,0x06,0x02,0x02,0x06,0x7E,0x7E,0x7C,0x70,0x00,
- 0xF0,0xFF,0xFF,0xFF,0xC1,0xE0,0x70,0x70,0x30,0x30,0x70,0xF0,0xF0,0xE0,0xC0,0x00,
- 0x3F,0xFF,0xFF,0xFF,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xFE,
- 0x00,0x03,0x0F,0x1F,0x3F,0x78,0x70,0x60,0x40,0x40,0x60,0x70,0x3F,0x1F,0x0F,0x03,
- },
- {//7
- 0x00,0xF8,0xFE,0x1E,0x0E,0x06,0x06,0x06,0x06,0x06,0x06,0xC6,0xF6,0x7E,0x1E,0x06,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xF8,0x7F,0x0F,0x03,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x80,0xF8,0xFF,0xFF,0x0F,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x7F,0x7F,0x7F,0x7F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- },
- {//8
- /*-- ¿í¶èx¸ß¶è=16x32 --*/
- 0x00,0xF0,0xF8,0xFC,0x0E,0x06,0x06,0x02,0x02,0x06,0x06,0x0E,0xFC,0xF8,0xF0,0x80,
- 0x00,0x0F,0x1F,0x3F,0xFC,0xF8,0xF0,0xE0,0xE0,0xC0,0xE0,0xF0,0x3F,0x1F,0x0F,0x01,
- 0xE0,0xFC,0xFE,0x1F,0x03,0x01,0x00,0x01,0x03,0x03,0x07,0x0F,0x7F,0xFE,0xFC,0xE0,
- 0x03,0x0F,0x1F,0x3C,0x70,0x60,0x60,0x40,0x40,0x60,0x60,0x70,0x3C,0x1F,0x0F,0x03,
- },
- {//9
- 0x80,0xF0,0xF8,0xFC,0x1E,0x06,0x06,0x02,0x02,0x06,0x0E,0x3C,0xFC,0xF0,0xE0,0x00,
- 0x7F,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xFF,0xFF,0xFF,0xFE,
- 0x00,0x03,0x07,0x07,0x0F,0x0E,0x0E,0x0C,0x0E,0x0E,0x07,0x83,0xFF,0xFF,0xFF,0x0F,
- 0x00,0x0C,0x3E,0x7E,0x7E,0x70,0x40,0x40,0x60,0x70,0x3C,0x1F,0x0F,0x07,0x00,0x00,
- }
- };
- void delay1ms(uchar x)
- {
- uint i,j;
- for(i = x;i > 0;i --)
- for(j = 110;j > 0;j --);
- }
- /**************Ö¸¶¨μú¼¸oáÅÅÏÔê¾ÄúèY 16*32********************/
- void WRITE_STRING1632(uchar plat,uchar column,uchar p)
- {
- uchar page,page1,col,col_h,col_l;
- uchar i,a,jj=0;
- page1= plat*2;
- page=page1+Page0;
- col=column*16;
- col_h=((col>>4)|0xf0)&0x1f;
- col_l=col&0x0f;
- for(a = 0; a < 4; a++)
- {
- LCD_WRITE_COM(col_h);
- LCD_WRITE_COM(col_l);
- LCD_WRITE_COM(page+a);
- for(i = 0; i < 16; i ++ )
- {
- LCD_WRITE_DATA(dazi[p][jj++]);
- }
- }
- }
- void keyscanf()
- {
- uchar temp, key;
- P2 = 0Xef;
- temp = P2;
- temp = temp & 0x0f;
- if(temp != 0x0f)
- {
- delay1ms(5);//襶¶¶ˉ
- temp=P2;
- temp = temp & 0x0f;
- if(temp != 0x0f)
- {
- temp = P2;
- switch(temp)//′Ëê±°′¼üòѾ-¶¨Î»μ½μúò»DDáË
- {
- case 0xe7: key = 1; break;//′Ëê±′ú±íμúò»DDμÄμúò»¸ö°′¼ü°′Ï£¬¼′11100111
- case 0xeb: key = 2; break;
- case 0xed: key = 3; break;
- }
- while(temp != 0x0f)//°′¼üËé¿a
- {
- temp = P2;
- temp = temp & 0x0f;
- }
- WRITE_STRING1632(1,3,key-1);
- }
- }
- P2 = 0Xdf;
- temp = P2;
- temp = temp & 0x0f;
- if(temp != 0x0f)
- {
- delay1ms(5);//襶¶¶ˉ
- temp = P2;
- temp = temp & 0x0f;
- if(temp != 0x0f)
- {
- temp = P2;
- switch(temp)
- {
- case 0xd7: key = 4; break;
- case 0xdb: key = 5; break;
- case 0xdd: key = 6; break;
- }
- while(temp != 0x0f)//°′¼üËé¿a
- {
- temp = P2;
- temp = temp & 0x0f;
- }
- WRITE_STRING1632(1,3,key-1);
- }
- }
- P2 = 0Xbf;
- temp = P2;
- temp = temp & 0x0f;
- if(temp != 0x0f)
- {
- delay1ms(5);//襶¶¶ˉ
- temp=P2;
- temp = temp & 0x0f;
- if(temp != 0x0f)
- {
- temp = P2;
- switch(temp)
- {
- case 0xb7: key = 7; break;
- case 0xbb: key = 8; break;
- case 0xbd: key = 9; break;
- }
- while(temp != 0x0f)//°′¼üËé¿a
- {
- temp = P2;
- temp = temp & 0x0f;
- }
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码 下载:
LCD1602显示1-9.zip
(39.61 KB, 下载次数: 49)
|