时间:2024.8.30
作者:Whappy
目的:手撕51(第二遍)
代码:
main.c
#include <REGX52.H>
#include "LCD1602.h"
#include "Delay.h"
#include "MatrixKey.h"
unsigned char KeyNum;
void main()
{
LCD_Init();
//LCD_ShowString(1,2,"Hello World");
while(1)
{
KeyNum = MatrixKey();
if(KeyNum)
{
LCD_ShowNum(1,1,KeyNum,2);
}
}
}
MatrixKey.c
#include <REGX52.H>
#include "Delay.h"
unsigned char MatrixKey()
{
unsigned char KeyNumber = 0;
/***************************************
软件按键消抖
如果P1_7按下则延时20ms,用while(P1_7 == 0);检测一下P1