求大神用c51编写一个单片机小程序

2024-12-25 21:39:15
推荐回答(1个)
回答1:

#include
#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< 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";
}
}
}