急求一个由89C51单片机的代码!要求用4*4矩阵键盘控制LED矩阵输出0~9的数字!
答案:1 悬赏:70
解决时间 2021-10-19 20:58
- 提问者网友:最美的风景
- 2021-10-19 11:31
急求一个由89C51单片机的代码!要求用4*4矩阵键盘控制LED矩阵输出0~9的数字!
最佳答案
- 二级知识专家网友:何以畏孤独
- 2021-10-19 12:43
可以了吧。能推荐答案给分吗, 也是反转写的,下次自己说要C的就行
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
void delay(uint k);
void display();
void keyscan();
uchar array[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar shuju[17]={0xee,0xed,0xeb,0xe7,0xde,0xdd,0xdb,0xd7,0xbe,0xbd,0xbb,0xb7,0x7e,0x7d,0x7b,0x77,0xff};
uchar z,x,a,b,c;
main()
{
while (1)
{
P2=0x00;
keyscan();
display();
}
}
void keyscan()
{
P1=0xf0;
a=P1;
P1=0x0f;
b=P1;
c=a|b;
for(x=0;c!=shuju[x];x++)
{
}
if(x==16)
{
x=0;
}
if(x!=0)
{
z=x;
}
}
void display()
{
P2=array[z];
delay(10);
}
void Delay(uint k)
{
while(--k);
}
#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
void delay(uint k);
void display();
void keyscan();
uchar array[16]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
uchar shuju[17]={0xee,0xed,0xeb,0xe7,0xde,0xdd,0xdb,0xd7,0xbe,0xbd,0xbb,0xb7,0x7e,0x7d,0x7b,0x77,0xff};
uchar z,x,a,b,c;
main()
{
while (1)
{
P2=0x00;
keyscan();
display();
}
}
void keyscan()
{
P1=0xf0;
a=P1;
P1=0x0f;
b=P1;
c=a|b;
for(x=0;c!=shuju[x];x++)
{
}
if(x==16)
{
x=0;
}
if(x!=0)
{
z=x;
}
}
void display()
{
P2=array[z];
delay(10);
}
void Delay(uint k)
{
while(--k);
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯