python七段数码管10秒倒计时_编程实现60秒的倒计时器程序,到最后10秒的时候数码管开始闪烁递减知道为0!请教这个闪烁子程序怎么编呢?...

这篇博客探讨了如何使用Python实现60秒倒计时器,特别是在最后10秒时数码管闪烁递减至0的编程问题。文章提供了C语言的数码管显示和倒计时基础代码,并求助于读者提供闪烁子程序的解决方案。
摘要由CSDN通过智能技术生成

#include#defineucharunsignedchar#defineuintunsignedintuchartime,temp,shi,ge;sbitduan=P2^2;//定义锁存使能端口段锁存sbitwei=P2^3;//定义锁存使能端口位锁存ucharcodet...

#include

#define uchar unsigned char

#define uint unsigned int

uchar time,temp,shi,ge;

sbit duan=P2^2; //定义锁存使能端口 段锁存

sbit wei=P2^3; //定义锁存使能端口 位锁存

uchar code table[]={

0x3f,0x06,0x5b,0x4f,

0x66,0x6d,0x7d,0x07,

0x7f,0x6f,0x77,0x7c,

0x39,0x5e,0x79,0x71};

void delay(uint z)

{

int x,y;

for(x=z;x>0;x--)

for(y=200;y>0;y--);

}

void init() //初始化子程序

{

duan=0;

wei=0;

time=0;

temp=20;

TMOD=0x01;//采用定时器T0,定时方式、方式1

TH0=(65536-50000)/256;//50毫秒;20次为1秒。

TL0=(65536-50000)%256;

EA=1; //开总中断

ET0=1; //T0溢出中断允许位。为1是打开,为0时禁止

TR0=1; //启动T0定时器

}

void display(uchar shi,uchar ge)

{

duan=1;

P0=table[shi];

duan=0;

P0=0xff;

wei=1;

P0=0xfe;

wei=0;

delay(1);

duan=1;

P0=table[ge];

duan=0;

P0=0xff;

wei=1;

P0=0xfd;

wei=0;

delay(1);

}

void display_shanshuo(uchar shi,uchar ge)//闪烁子程序

{

???????????????????

???????????????????

???????????????????

}

void main()

{

init();

while(1)

{

if(time==20)

{

time=0;

temp--;

if(temp==0)

temp=20;

shi=temp/10;

ge=temp%10;

}

if(temp>10)

display(shi,ge);

if(temp<11)

display_shanshuo(shi,ge);

}

}

void timer() interrupt 1

{

TH0=(65536-50000)/256;

TL0=(65536-50000)%256;

time++;

}

请教各位高手,程序当中的闪烁子程序怎么编写呢?才能实现数码管正常递减并且是相隔1秒的时间在闪烁!

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值