📄 单片机应用ps-2键盘的实例.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0047)http://www.cdle.net/alldata/mywz/04030701_1.htm -->
<HTML><HEAD><TITLE>磁动力工作室--单片机应用PS/2键盘的实例</TITLE><!-- #BeginTemplate "/Templates/文章模板.dwt" --><!-- #BeginEditable "doctitle" --><!-- #EndEditable -->
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE type=text/css>@import url( ../../Css/all.css );
</STYLE>
<META content="MSHTML 6.00.2800.1106" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0>
<TABLE cellSpacing=0 cellPadding=0 width="100%" align=center border=0>
<TBODY>
<TR bgColor=#99cc00>
<TD></TD>
<TD width=760>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=15 rowSpan=3></TD>
<TD width=151 rowSpan=3><IMG height=65
src="单片机应用PS-2键盘的实例.files/logo.gif" width=151></TD>
<TD width=510 rowSpan=3>
<DIV align=center><!-- #BeginEditable "TOP%20AD" --><!-- #BeginLibraryItem "/Library/ad2.lbi" --><IMG
height=60 src="" width=468 border=0><!-- #EndLibraryItem -->.<!-- #EndEditable --></DIV></TD>
<TD height=22>
<DIV align=right><A name=TOP></A><IMG height=6
src="单片机应用PS-2键盘的实例.files/go5.gif" width=5> <A class=T12_W1
href="http://www.cdle.net/about.htm"
target=_blank>关于站点</A> </DIV></TD></TR>
<TR>
<TD height=22>
<DIV align=center><IMG height=6 src="单片机应用PS-2键盘的实例.files/go5.gif"
width=5 border=0> <A
onclick="window.external.AddFavorite('http://www.cdle.net', '磁动力工作室')"
href="http://www.cdle.net/alldata/mywz/04030701_1.htm#"><SPAN
class=T12_W1>收藏本站</SPAN></A></DIV></TD></TR>
<TR>
<TD height=22>
<DIV align=center><IMG height=6 src="单片机应用PS-2键盘的实例.files/go5.gif"
width=5 border=0> <A href="mailto:pnzwzw@cdle.net"><SPAN
class=T12_W1>联系站长</SPAN></A></DIV></TD></TR></TBODY></TABLE></TD>
<TD></TD></TR>
<TR>
<TD bgColor=#99cc00 height=10><IMG height=1
src="单片机应用PS-2键盘的实例.files/zo.gif" width=1></TD>
<TD width=760 bgColor=#cccc99 height=20 rowSpan=2><!-- #BeginLibraryItem "/Library/导航栏.lbi" -->
<TABLE cellSpacing=1 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD background=单片机应用PS-2键盘的实例.files/bg1.gif height=20> <A
class=T12_R1 href="http://www.cdle.net/index.htm">首页</A> | <A
class=T12_B2
href="http://www.cdle.net/alldata/mywz/index.htm">原创作品</A> | <A
class=T12_B2
href="http://www.cdle.net/alldata/shop/index.htm">网站产品</A> | <A
class=T12_B2
href="http://www.cdle.net/alldata/mcu/index.htm">单片机技术</A> | <A
class=T12_B2
href="http://www.cdle.net/alldata/robot/index.htm">机器人DIY</A> | <A
class=T12_B2
href="http://www.cdle.net/alldata/data/index.htm">应用资料</A> | <A
class=T12_B2
href="http://www.cdle.net/alldata/school/index.htm">初学园地</A> | <A
class=T12_B2 href="http://bbs.cdle.net/">论坛</A> | <A class=T12_B2
href="http://www.cdle.net/alldata/FAQ/index.htm">FAQ</A></TD></TR></TBODY></TABLE><!-- #EndLibraryItem --></TD>
<TD bgColor=#99cc00 height=10><IMG height=1
src="单片机应用PS-2键盘的实例.files/zo.gif" width=1></TD></TR>
<TR>
<TD height=10><IMG height=1 src="单片机应用PS-2键盘的实例.files/zo.gif" width=1></TD>
<TD height=10><IMG height=1 src="单片机应用PS-2键盘的实例.files/zo.gif"
width=1></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD> </TD>
<TD width=760>
<TABLE height=20 cellSpacing=0 cellPadding=0 width="100%" align=center
border=0>
<TBODY>
<TR>
<TD width=560><!-- #BeginEditable "t1" --><!-- #EndEditable --></TD>
<TD width=120> <IMG height=16 alt=点击数量
src="单片机应用PS-2键盘的实例.files/click.gif" width=18>点击数 <!-- #BeginEditable "t2" -->
<SCRIPT language=JavaScript
src="单片机应用PS-2键盘的实例.files/wclick.htm"></SCRIPT>
<!-- #EndEditable --></TD>
<TD width=80> <IMG height=6 src="单片机应用PS-2键盘的实例.files/go5.gif"
width=5> <A class=T12_B1 href="javascript:window.close()">关 闭</A>
<IMG height=6 src="单片机应用PS-2键盘的实例.files/go4.gif"
width=5></TD></TR></TBODY></TABLE></TD>
<TD> </TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD> </TD>
<TD class=TB1 width=760 bgColor=#cccc99>
<TABLE cellSpacing=1 cellPadding=1 width="100%" border=0>
<TBODY>
<TR>
<TD bgColor=#ffffff>
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD width=5><IMG height=1 src="单片机应用PS-2键盘的实例.files/zo.gif"
width=1></TD>
<TD class=TB1><!-- #BeginEditable "main" -->
<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
<TBODY>
<TR>
<TD height=10>
<DIV class=title1
align=center>单片机应用PS/2键盘的实例</DIV></TD></TR>
<TR>
<TD height=10>
<DIV align=center>作 者: 明浩 出 处: 磁动力工作室 <A
href="http://www.cdle.net/"
target=_blank>http://www.cdle.net/</A> <A
href="mailto:pnzwzw@cdle.net">mailto:pnzwzw@cdle.net</A>(ID196)</DIV></TD></TR>
<TR>
<TD vAlign=top>
<TABLE cellSpacing=0 cellPadding=0 width="100%"
align=center border=0>
<TBODY>
<TR vAlign=top>
<TD class=l12r>
<DIV align=center><IMG height=300
src="单片机应用PS-2键盘的实例.files/04030701_1_P1.jpg"
width=400> <BR><BR><A
href="http://www.cdle.net/alldata/mywz/pic/04030701_1_P2B.gif"
target=_blank><IMG height=276 alt=点击放大
src="单片机应用PS-2键盘的实例.files/04030701_1_P2.gif"
width=500 border=0></A> <BR>点击放大</DIV></TD></TR>
<TR vAlign=top>
<TD class=l12r><BR><A
href="http://www.cdle.net/wzadmin/download.asp?autoid=199"
target=_blank>SMC1602A液晶显示屏资料</A> <A
href="http://www.cdle.net/alldata/data/04030701_SMC1602A.pdf"
target=_blank><IMG height=41 alt=点击下载PDF文件
src="单片机应用PS-2键盘的实例.files/pdf.gif" width=30
border=0></A><BR><BR>ps2key.c<BR>/*============================================================<BR>使用1602液晶显示和PS/2键盘的示例
明浩
2004/2<BR>-------------------------------------------------<BR>http://www.cdle.net
http://bbs.cdle.net<BR>==============================================================
<P>SMC1602A(16*2)模拟口线接线方式<BR>连接线图:
<BR>---------------------------------------------------<BR>|LCM-----51
| LCM-----51 | LCM------51
|<BR>--------------------------------------------------|<BR>|DB0-----P1.0
| DB4-----P1.4 | RW-------P2.0 |<BR>|DB1-----P1.1
| DB5-----P1.5 | RS-------P2.1 |<BR>|DB2-----P1.2
| DB6-----P1.6 | E--------P2.2 |<BR>|DB3-----P1.3
| DB7-----P1.7 |
VLCD接1K电阻到GND|<BR>---------------------------------------------------</P>
<P>Keyboard接线<BR>PS/2--------51<BR>1
DATA------P3.4<BR>3 GND<BR>4 VCC<BR>5
CLK-------P3.3 接在51的外部中断,触发方式为低电平</P>
<P>本程序源码只供学习参考,不得应用于商业用途,如有需要请联系作者。</P>
<P>[注:AT89x51使用12M或11.0592M晶振,实测使用11.0592M]<BR>[Keil
uV2 7.01编译运行通过 程序中没有做键盘数据的奇偶校验]</P>
<P>=============================================================*/<BR>#include
<at89x51.h><BR>#include "scancodes.h"</P>
<P>#define LCM_RW P2_0 //定义LCD引脚<BR>#define LCM_RS
P2_1<BR>#define LCM_E P2_2<BR>#define LCM_Data
P1</P>
<P>#define Key_Data P3_4 //定义Keyboard引脚<BR>#define
Key_CLK P3_3</P>
<P>#define Busy 0x80 //用于检测LCM状态字中的Busy标识</P>
<P>void LCMInit(void);<BR>void
DisplayOneChar(unsigned char X, unsigned char Y,
unsigned char DData);<BR>void
DisplayListChar(unsigned char X, unsigned char Y,
unsigned char code *DData);<BR>void
Delay5Ms(void);<BR>void Delay400Ms(void);<BR>void
Decode(unsigned char ScanCode);<BR>void
WriteDataLCM(unsigned char WDLCM);<BR>void
WriteCommandLCM(unsigned char WCLCM,BuysC);</P>
<P>unsigned char ReadDataLCM(void);<BR>unsigned
char ReadStatusLCM(void);<BR>unsigned char code
cdle_net[] = {"-www.cdle.net--"};<BR>unsigned char
code email[] = {"pnzwzw@cdle.net"};<BR>unsigned
char code Cls[] = {" "};<BR>static unsigned char
IntNum = 0; //中断次数计数<BR>static unsigned char KeyV;
//键值<BR>static unsigned char DisNum = 0;
//显示用指针<BR>static unsigned char Key_UP=0, Shift =
0;//Key_UP是键松开标识,Shift是Shift键按下标识<BR>static
unsigned char BF = 0; //标识是否有字符被收到</P>
<P>void main(void)<BR>{<BR>unsigned char
TempCyc;</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -