/*
*AVR scan Keybord demo
*------------------------
*DESIGNED:yingxian_Fei
*2012-2-25
*This demo code use for show the action after someone pressed the keybord.
*The program show the action to user by light LED.
*/
#include <reg51.h>
#include <intrins.h>
#include <stdio.h>
#include <stdlib.h>
#define POUT P0 //设置输出的P口
#define MASK 0xff
#define LEDCON 0x03
sfr AUXR = 0x8E;
sbit KEY1 = P2^0;
sbit KEY2 = P2^1;
sbit KEY3 = P2^2;
sbit KEY4 = P2^3;
void AppCall(void);
void Task1(void);
void Task2(void);
void Task3(void);
void Task4(void);
void InitMCU(void);
void InitTimer0(void);
void KeyBord(void);
void Delay_ms(unsigned char ms);
unsigned char

本文介绍了一个基于STC12C5A60S2单片机的按键扫描程序,演示了按键查询方式及防抖动处理。程序中,按键按下会触发不同LED灯亮起,模拟执行不同任务。用户可以通过宏定义选择输出端口,默认使用P0口。此程序旨在提供娱乐和学习参考。
最低0.47元/天 解锁文章
2129

被折叠的 条评论
为什么被折叠?



