用AT89C51单片机实现四位数码管显示数据!!用c语言程序实现!!例如显
发布网友
发布时间:2022-05-01 04:32
我来回答
共1个回答
热心网友
时间:2023-10-05 02:04
#include<reg51.h>
#define uchar unsigned char
uchar tab[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00}; //0到9
uchar num;
uchar led[]={0,4,1,2};
void t0isr() interrupt 1
{
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
switch(num)
{
case 0:P2=0x01;break;
case 1:P2=0x02;break;
case 2:P2=0x04;break;
case 3:P2=0x08;break;
default:break;
}
P0=~tab[led[num]];
num++;
num&=0x03;
}
main()
{
TMOD=0x11;
TH0=(65536-5000)/256;
TL0=(65536-5000)%256;
TR0=1;
ET0=1;
EA=1;
while(1);
}