51单片机输入数字并数码管倒计时典型C语言代码
使用STC89C52RC单片机,外接数码管、蜂鸣器。改代码非常适合初学者学习借鉴。
#include
#define uchar unsigned char
#define uint unsigned int
sbit dula=P0^0;
sbit wela=P0^1;
sbit p17=P0^3;
sbit p02=P0^2;
sbit p32=P3^2;
sbit p04=P0^4;
uchar count;
uint Sumnum;
uint circle,circle1;
uint time;
float top;//定义top为浮点型变量
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71};
uchar temp,count;
uint bian,num,e,d,c,b,a;
void delay(uchar x)
{
uchar a1,b1;
for(a1=x;a1>0;a1--)
for(b1=200;b1>0;b1--);
}
void chaishu(uint sum1)
{
uint e1,b1,c1,d1;
e=sum1/10000;e=6*