#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code seg[10] = {0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x90};
uchar code location[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
uchar cache[8] = {0, 0, 0, 0, 0, 0, 0, 0};
bit flag = 0;
uchar keyNum = 0;
sbit P10 = P1^0;
sbit P11 = P1^1;
sbit P12 = P1^2;
sbit P13 = P1^3;
sbit P14 = P1^4;
sbit P15 = P1^5;
sbit P16 = P1^6;
sbit P17 = P1^7;
void Change(uchar a, b, c, d, e, f, g, h)
{
cache[0] = a;
cache[1] = b;
cache[2] = c;
cache[3] = d;
cache[4] = e;
cache[5] = f;
cache[6] = g;
cache[7] = h;
}
void Delay(uint ms)
{
uint i = 0;
uchar j = 0;
for(i = ms; i > 0; i--)
for(j = 120; j > 0; j--);
}
void Display()
{
uchar i = 0;
for(i = 0; i < 8; i++)
{
P3 = location[i];
P2 = 0xff;
P2 = seg[cache[i]];
}
}
void KeyScan()
{
uchar x = 0;
uchar y = 0;
if(flag == 0)
{
P1 = 0x0f;
if(P10 == 0 || P11 == 0 || P12 == 0 || P13 == 0)
{
if(P10 == 0)
x = -1;
if(P11 == 0)
x = 3;
if(P12 == 0)
x = 7;
if(P13 == 0)
x = 11;
}
P1 = 0xf0;
if(P14 == 0 || P15 == 0 || P16 == 0 || P17 == 0)
{
if(P14 == 0)
y = 4;
if(P15 == 0)
y = 3;
if(P16 == 0)
y = 2;
if(P17 == 0)
y = 1;
}
if(y == 0)
flag = 0;
else
{
keyNum = x + y;
flag = 1;
}
}
}
void main()
{
while(1)
{
KeyScan();
if(flag == 0)
flag = 1;
Change(0, 0, 0, 0, 0, 0, keyNum / 10, keyNum % 10);
Display();
}
}
大富大贵7
- 粉丝: 389
- 资源: 8868
最新资源
- C#OA+HR+CRM源码 综合办公管理系统源码数据库 SQL2008源码类型 WebForm
- (源码)基于Python的火车票管理系统.zip
- springboot中删除数据时,数据库中的表关联了其他表,怎么删除?
- (源码)基于Spring Boot的博客系统.zip
- (源码)基于Java的招聘网站职位数据分析系统.zip
- (源码)基于Spring Boot和Quartz的火车票务管理系统.zip
- (源码)基于C#的RFID门禁控制系统.zip
- 实验二 枚举与分治.docx
- (源码)基于OpenCV和mediapipe的无人机肢体学模拟教学系统.zip
- web_1731508854623.png
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈