#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wale=P2^7;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delayms(uint);
void display(uchar,uchar);
uchar num, num1,shi,ge,beep;
void main()
{
TMOD=0x01;
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
EA=1;
ET0=1;
TR0=1;
while(1)
{
display(shi,ge);
}}
void display(uchar shi,uchar ge)
{
dula=1;
P1=table[ge];
dula=0;
delayms(5);
wale=1;
P1=table[shi];
wale=0;
delayms(5);
}
void T0_time() interrupt 1
{
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
num1++;
if(num1==20)
{
num1=0;
num--;
if(num==0)
num=60;
delayms(1);
shi=num/10;
ge=num%10;
}}
void delayms(uint xms)
{
uint i,j;
for(i=xms;i>0;i--)
for(j=110;j>0;j--);
}
求教,利用51单片机编写两个数码管60秒倒计时,个位是从5开始计时之后才...
如楼上所说,你没有初始化num这个参数,那么默认值就是0,也相当于256,所以一开始进入中断就是256-1,也就是255,个位是5,十位数是25,所以显示就成了你现在的模样。因此初始化以下就好了。
小白求救,51单片机利用两个数码管实现60秒倒计时?
include <reg51.h> unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};void show(unsigned char n);void delay(unsigned int k);void main(){ unsigned char i;int j;while(1){ for(i=60;j=60,i>0;i--)while(j--)show(i);} } void show(unsi...
求C51单片机汇编语言控制两位数码管倒计时程序,最好能说明下思路_百度...
MOV P0,A SETB P2.1
51单片机接2个led数码管,怎么让数码管倒计时?
先看看下面程序,看懂了,就知道咋编了 include<reg52.h> define uchar unsigned char define uint unsigned int uchar a , b=0;sbit wei1=P1.0;sbit wei2=P1.1;\/\/共阴数码管七段码 uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d, 0x07,0x7f,0x6f,0x77};void ...
单片机60秒倒计时程序怎么写啊!!!这个图的!!!急用啊!!!
1; TR0 = 1;while(1);}void Timer0Interrupt(void) interrupt 1{static unsigned int i = 0;static char time = 60; TH0 = 0xFC; TL0 = 0x66;P3 = table[time%10];P2 = table[time\/10];i++;if (i >= 1000){i = 0;time--;if (time < 0){time = 60;}}}...
使用2个数码管设计一个60秒倒计时C语言程序,要求用定时器中断定时1秒...
7SEG-COM-CATHODE 为共阴管 include<reg51.h> define uchar unsigned char define uint unsigned int uchar num=60,shi,ge;uchar code TAB[]={ 0x3F,\/*0*\/ 0x06,\/*1*\/ 0x5B,\/*2*\/ 0x4F,\/*3*\/ 0x66,\/*4*\/ 0x6D,\/*5*\/ 0x7D,\/*6*\/ 0x07,\/*7*\/ 0x7F,\/*8*\/ 0x6F,\/*...
编程实现倒计时的秒表,2位LED数码管显示,延时采用硬件延时的方法_百 ...
用单片机的定时器T0定时,计时1秒,实现倒计时的秒表的功能。程序如下 include<reg51.h> unsigned char code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};\/\/共阳数码管段码表 unsigned char second;\/\/秒倒计时变量 unsigned char t0n;\/\/T0中断次数计数 sbit k1=P3^2;\/...
51单片机两个阳极数码管显示24倒计时怎么显示00
1、基于51单片机共阴两位数码管显示倒计时#includeunsigned char s=0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f;unsigned char count,d1,d2,g,y;signed int time=10; void delay(unsigned char i);void sm()d1=time\/10;d2=time%10;P1=sd1;P3=0x00;delay(2);P3=0x01;P1...
求两位数码管显示一个倒数时间的单片机程序,比如显示从99到0
\/\/两位数码管显示倒计数99~00,51单片机。include<reg52.h> \/\/ 倒计数 define uint unsigned int define uchar unsigned char uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};uchar bai,shi;uint a1,a2;sbit D1=P3^...