【Proteus仿真】键盘矩阵扫描+LCD128x64显示

【Proteus仿真】键盘矩阵扫描+LCD128x64显示


  • Proteus仿真演示
    在这里插入图片描述

汉字取模工具和取模方式

  • 取模工具:PCtoLCD2002
  • 取模方式:阴码、逆向、列行式、C51格式、
    在这里插入图片描述

主程序代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <reg51.h>
#include <intrins.h>
#include "LCD\_12864.H"
#include "KeyPad.H"
#include "DotMatri.H"
#define uchar unsigned char
#define uint unsigned int

//键盘扫描开启标志其值由外部中断 0 控制
bit KeyPressDown = 0;
uchar T_Count = 0;
sbit SPK = P3^7;
//Keybord\_Chars 中数字与符号编码与键盘按键对照表
uchar code KeyPosTable[]=
{
7,8,9,10,
4,5,6,11,
1,2,3,12,
15,0,14,13
};
//蜂鸣器发声
void Beep()
{
uchar i,x=20;
while (x--)
{
for(i=0; i<120; i++);
SPK=~SPK;
}
}
//主程序
void main()
{
uchar i;
LCD\_Initialize(); //初始化 LCD
for (i=0; i<7; i++) //从第一页开始左边距 16 点显示 7 个 16\*16 点阵的中文提示信息
Display\_A\_WORD\_String (1,16\*(i+1),1,Word_String[i]);
P1=0x0f;
IE=0x83; //允许外部 0 和定时器 0 中断
IT0=1; //设为下降沿中断方式外部中断 0 用于启停键盘
TH0=(65536-5000)/256;//50ms 定时
TL0=(65536-5000)%256;
while(1)
{
//如果有按键按下则处理按键
if(KeyPressDown==1)
{//扫描处理
Beep();
KeyPressDown=0;
Display\_A\_char(4,55,Keyboard_Chars[KeyPosTable[KeyScan()] ]);
TR0=0;
}
}
}
//外部中断 0 控制消抖延时
void EX0\_INT() interrupt 0
{
TR0=1;//开启定时器 0延时 300ms 消抖
}
//定时器用于消抖并确认有键按下启动主程序中的按键扫描
void T0\_INT() interrupt 1
{
if(++T_Count==6) //50\*6=300ms 延时抖动
{
T_Count=0;
KeyPressDown=1; //确定有键按下
}
TH0=(65526-50000)/256; //50ms 定时
TL0=(65526-50000)%256;
}

  • 工程架构以及编译信息
    在这里插入图片描述

仿真资源和程序源码

本示例基于Proteus8.12平台

1
2
3
链接:https://pan.baidu.com/s/1qdwGTMi5dLT55ZdDuTKYjA 
提取码:4vtv


在这里插入图片描述

对待生活,取舍有度
百事从心起 ,一笑解千愁