STC单片机按键扫描程序演示

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



/*
 *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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值