#include<reg52.h>
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
sbit H1=P1^0;
sbit H2=P1^1;
sbit H3=P1^2;
sbit H4=P1^3;
sbit L1=P1^4;
sbit L2=P1^5;
sbit L3=P1^6;
sbit L4=P1^7;
uchar keynum1=0;
uchar a=0;
bit keyflag=0;
bit keyscan();
char keynumscan(uchar key);
void delay();
uchar code distable[]={0x28,0x0eb,0x32,0x0a2,0x0e1,0x0a4,0x24,0x0ea,0x20,0x0a0,0x25,0x83,0x0c6,0x0a1,0x86,0x8e};
void main()
{
TMOD=0x01;
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
if(keyflag)
{
keyflag=0;
if(a=(keynumscan(0xfe)))
keynum1=a-0x01;
else if(a=(keynumscan(0xfd)))
keynum1=a+0x03;
else if(a=(keynumscan(0xfb)))
keynum1=a+0x07;
else if(a=(keynumscan(0xf7)))
keynum1=a+0x0b;
else
;
TR0=1;
}
P2=0x7f;
P1=keynum1;
P0=distable[keynum1];
}
}
bit keyscan()
{
uchar temp;
P1=0xf0;
temp=P1;
if(temp!=0xf0)
{
delay();
if(temp!=0xf0)
// keyflag=1;
return 1;
}
else
{
//P1=0xff;
//keyflag=0;
return 0;
}
}
char keynumscan(uchar key)
{
uchar temp,keynum;
P1=key;
temp=P1;
if(temp!=key)
{
if(!L1)
keynum=0x01;
else if(!L2)
keynum=0x02;
else if(!L3)
keynum=0x03;
else
keynum=0x04;
P1=key;
temp=P1;
while(temp!=key)
{
P1=key;
temp=P1;
}
return keynum;
}
else
{
//P1=0xff;
return(0);
}
}
void delay()
{
uchar x,y;
for(x=10;x>0;x--)
for(y=110;y>0;y--);
}
void timer0() interrupt 1 using 0
{
TR0=0;
TH0=(65536-10000)/256;
TL0=(65536-10000)%256;
if(keyscan())
keyflag=1;
else
{
keyflag=0;
TR0=1;
}
}
44矩阵键盘DS18B20显示
需积分: 10 145 浏览量
2009-08-11
17:33:08
上传
评论
收藏 39KB RAR 举报
renwei19870929
- 粉丝: 0
- 资源: 1
最新资源
- IMG_20240423_191216.jpg
- 基于MATLAB实现分析黑体辐射光谱图时将通过迈克尔逊干涉仪得到干涉图经过傅里叶变换转换为光谱图的功能源码.zip
- DynamicArray02.java
- 数据可视化 matplotlib 实例.docx
- 数据可视化 matplotlib 实例.7z
- Python 使用 Matplotlib 绘制甘特图的实践.7z
- Python 使用 Matplotlib 绘制甘特图的实践.docx
- matplotlib 中的 cmap 参数介绍.docx
- matplotlib 中的 cmap 参数介绍.7z
- 基于matlab的毕业设计基于Matlab使用LQR实现车辆轨迹跟踪源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈