标题:
单片机AT89C51外接4 位共阳LED 数码管
[打印本页]
作者:
2315695146
时间:
2018-5-28 19:44
标题:
单片机AT89C51外接4 位共阳LED 数码管
单片机AT89C51外接4 位共阳LED 数码管,P3.0引脚外接一独立按键。开机
时数码管显示数字2018; 在按下按键时,显示月日期,设计单片机接口电路并编程
#include<reg51.h>
#include "intrins.h"
#include "absacc.h"
#define uchar unsigned char
uchar code ledtab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40,0xff};//0-9
unsigned char disdat[4]="2018";
sbit key=P3^0;
void ext0() interrupt 0
{
key++;
key%=3;
}
void t1isr() interrupt 3 //显示
{
TH1=0xec;
TL1=0x78;
P0=0xff;
P2=0x01<<scanled;
P0=~ledtab[disdat[3]];
scanled++;
scanled%=4;
}
main()
{
TMOD=0x10;
TH1=0xec;
TL1=0x78;
TR1=1;
ET1=1;
EA=1;
while(1)
{
if(key==0)
{
disdat[]="0423";
while(key==0);
disdat[]="2018";
}
}
}
复制代码
作者:
admin
时间:
2018-5-29 01:26
此贴需要补全源码和图纸后才能获得积分
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1