电子码表

/* Main.c file generated by New Project wizard
*
* Created: ?? 5? 18 2017
* Processor: AT89C51
* Compiler: Keil for 8051
*/

#include <reg52.h>
#include <stdio.h>
#define uchar unsigned char

uchar u = 0,scond = 0;
uchar duan[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay()
{

uchar j = 100;
while(j--);
}
void main(void)
{

TMOD = 0x01;
ET0 = 1;
TR0 = 1;
EA = 1;
TH0 = (65535-50000)/256;
TL0 = (65535-50000)%256;

P2 = duan[scond/10];
P3 = duan[scond%10];

while(1);
}
void timer(void) interrupt 1
{
TH0 = (65535-50000)/256;
TL0 = (65535-50000)%256;
u++;
if(u == 20)
{
u = 0;
scond++;
if(scond == 60)
{
scond = 0;

}
}

P2 = duan[scond/10];
P3 = duan[scond%10];
}

原文地址:https://www.cnblogs.com/2277098974-qqcom/p/6886010.html