没有合适的资源?快使用搜索试试~ 我知道了~
首页89C52RC 按键消抖控制数码管程序
资源详情
资源评论
资源推荐

按键消抖独立控制数码管,共同学习……
#include <reg52.h>
code unsigned char zixing_table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
code unsigned char wei_table[]={~0x01, ~0x02, ~0x04, ~0x08, ~0x10, ~0x20, ~0x40, ~0x80};
unsigned char disbuf[8]=0;
unsigned char count,counter,flag10msok,flag100msok;
sbit P1_0 = P1^0;//定义按键与引脚的链接
sbit P1_1 = P1^1;
sbit P1_2 = P1^2;
sbit P1_3 = P1^3;
sbit P1_4 = P1^4;
sbit P1_5 = P1^5;
sbit P1_6 = P1^6;
sbit P1_7 = P1^7;
unsigned char postion;
void display(void)//扫描数码管
{
P0 = zixing_table[disbuf[postion]];
P2 = wei_table[postion];
if(++postion>=8)
postion=0;
}
void timer0_isr(void) interrupt 1//中断服务程序
{
TL0=0xCD;
TH0=0xF8;
display();
if(++count>=5)
{
count=0;
flag10msok=1;
}
if(++counter>=50)
{
counter=0;
flag100msok=1;
}
}
unsigned char getkey0(void)//按键程序
{
if(!P1_0)
















安全验证
文档复制为VIP权益,开通VIP直接复制

评论1