有没有单片机的大神帮我做一下 数码管显示4×4键盘矩阵按键 要求用汇编语言,谢谢了 10
参照电路硬件设计,编写一段程序。此电路为动态键盘输入电路。LED显示器件是数码管LED。按键上有标号。每个按键按下,控制数码管LED显示按键的第二个字符。例如按下K5后,...
参照电路硬件设计,编写一段程序。此电路为动态键盘输入电路。LED显示器件是数码管LED。按键上有标号。每个按键按下,控制数码管LED显示按键的第二个字符。例如按下K5后,数码管显示数字5,按KF,显示F。给出程序说明。数码管为共阴极形式RP为上拉电阻,电阻排形式。
展开
1个回答
展开全部
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit BEEP = P3^7;
uchar code DSY_CODE[]=
{
0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x00
};
uchar Pre_KeyNO = 16,KeyNO = 16;
void DelayMS(uint ms)
{
uchar t;
while(ms--)
{
for(t=0;t<120;t++);
}
}
void Keys_Scan()
{
uchar Tmp;
P1 = 0x0f;
DelayMS(1);
Tmp = P1 ^ 0x0f;
switch(Tmp)
{
case 1: KeyNO = 0; break;
case 2: KeyNO = 1; break;
case 4: KeyNO = 2; break;
case 8: KeyNO = 3; break;
default: KeyNO = 16;
}
P1 = 0xf0;
DelayMS(1);
Tmp = P1 >> 4 ^ 0x0f;
switch(Tmp)
{
case 1: KeyNO += 0; break;
case 2: KeyNO += 4; break;
case 4: KeyNO += 8; break;
case 8: KeyNO += 12;
}
#define uchar unsigned char
#define uint unsigned int
sbit BEEP = P3^7;
uchar code DSY_CODE[]=
{
0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e,0x00
};
uchar Pre_KeyNO = 16,KeyNO = 16;
void DelayMS(uint ms)
{
uchar t;
while(ms--)
{
for(t=0;t<120;t++);
}
}
void Keys_Scan()
{
uchar Tmp;
P1 = 0x0f;
DelayMS(1);
Tmp = P1 ^ 0x0f;
switch(Tmp)
{
case 1: KeyNO = 0; break;
case 2: KeyNO = 1; break;
case 4: KeyNO = 2; break;
case 8: KeyNO = 3; break;
default: KeyNO = 16;
}
P1 = 0xf0;
DelayMS(1);
Tmp = P1 >> 4 ^ 0x0f;
switch(Tmp)
{
case 1: KeyNO += 0; break;
case 2: KeyNO += 4; break;
case 4: KeyNO += 8; break;
case 8: KeyNO += 12;
}
追问
想要汇编语言的,不要C语言
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询