📄 ps2key_main.c
字号:
/*============================================================
使用1602液晶显示和PS/2键盘的示例 明浩 2004/2
-------------------------------------------------
http://www.cdle.net http://bbs.cdle.net
==============================================================
SMC1602A(16*2)模拟口线接线方式
连接线图:
---------------------------------------------------
|LCM-----51 | LCM-----51 | LCM------51 |
--------------------------------------------------|
|DB0-----P1.0 | DB4-----P1.4 | RW-------P2.0 |
|DB1-----P1.1 | DB5-----P1.5 | RS-------P2.1 |
|DB2-----P1.2 | DB6-----P1.6 | E--------P2.2 |
|DB3-----P1.3 | DB7-----P1.7 | VLCD接1K电阻到GND|
---------------------------------------------------
Keyboard接线
PS/2--------51
1 DATA------P3.4
3 GND
4 VCC
5 CLK-------P3.3 接在51的外部中断,触发方式为低电平
本程序源码只供学习参考,不得应用于商业用途,如有需要请联系作者。
[注:AT89x51使用12M或11.0592M晶振,实测使用11.0592M]
[Keil uV2 7.01编译运行通过 程序中没有做键盘数据的奇偶校验]
=============================================================*/
#include "reg51.h"
#include "scancodes.h"
#include "MAX7219.h"
#include "PS2Key.h"
#include "max7219.c"
#include "PS2key.c"
unsigned char key_number;
void main(void)
{
Init_PS2();
Init_MAX7219();
MAX7219_Command(dataaddr+2,0);
MAX7219_Command(dataaddr+3,0);
MAX7219_Command(dataaddr+6,0);
MAX7219_Command(dataaddr+7,0);
do
{
if (BF)
Decode(KeyV);
else
EA = 1; //开中断
}
while(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -