#include <REGX52.H>
#include "Delay.h"
#include "MatrixKey.h" //包含矩阵键盘头文件
#define uchar unsigned char
unsigned char KeyNum;
uchar key_scan(void);
//数码管段码表
unsigned code seg[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F};
//uchar dis[8]={0,1,2,3,4,5,6,7};
uchar chocode[8]={0xFE,0xFD,0xFB,0xF7,0xEF,0xDF,0xBF,0x7F};
//数码管显示子函数
uchar i,p,temp;
unsigned char displayIndex;
unsigned char PORT_DISPLAY;
unsigned char inputIndex;
unsigned char password[6]={0};
void DisplayDigit(unsigned char digit, unsigned char position);
int main()
{
unsigned char keyValue;
while (1)
{
keyValue = MatrixKey();
if (keyValue > 0 && keyValue <= 9 && inputIndex < 6)
{
password[inputIndex] = keyValue;
DisplayDigit(keyValue, inputIndex);
inputIndex++;
}
}
return 0;
}
|