完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
请大神看下我的代码,我想让小时段满24进1成00;可是小时段总是满100 进位,请大神指点一下,谢谢
#include #define uchar unsigned char ***it dula = P2^6; ***it wela = P2^7; uchar e0,e1,e2,e3,e4,e5,e6,e7,num,time; uchar code table[] = { 0x3f,0x06,0x5b,0x4f, 0x66,0x6d,0x7d,0x07, 0x7f,0x6f}; void init(); void display(uchar,uchar,uchar,uchar,uchar,uchar,uchar,uchar); void delay(uchar); void main() { init(); while(1) { display(e0,e1,e2,e3,e4,e5,e6,e7); } } void init() { num = 0; time = 0; TMOD = 0x11; TH0 = (65536-91)/256; //9174 TL0 = (65536-91)%256; EA = 1; ET0 = 1; TR0 = 1; } void display(uchar e0,uchar e1,uchar e2,uchar e3,uchar e4,uchar e5,uchar e6,uchar e7) { dula = 1; P1 = table[e0]; dula = 0; P0 = 0xff; wela = 1; P0 = 0x7f; wela = 0; delay(5); dula = 1; P1 = table[e1]; dula = 0; P0 = 0xff; wela = 1; P0 = 0xbf; wela = 0; delay(5); dula = 1; P1 = table[e2]; dula = 0; P0 = 0xff; wela = 1; P0 = 0xdf; wela = 0; delay(5); dula = 1; P1 = table[e3]; dula = 0; P0 = 0xff; wela = 1; P0 = 0xef; wela = 0; delay(5); dula = 1; P1 = table[e4]; dula = 0; P0 = 0xff; wela = 1; P0 = 0xf7; wela = 0; delay(5); dula = 1; P1 = table[e5]; dula = 0; P0 = 0xff; wela = 1; P0 = 0xfb; wela = 0; delay(5); dula = 1; P1 = table[e6]; dula = 0; P0 = 0xff; wela = 1; P0 = 0xfd; wela = 0; delay(5); dula = 1; P1 = table[e7]; dula = 0; P0 = 0xff; wela = 1; P0 = 0xfe; wela = 0; delay(5); } void delay(uchar xms) { uchar i,j; for(i = xms;i>0;i--) for(j = 110;j>0;j--); } void role0() interrupt 1 { TH0 = (65536-91)/256; TL0 = (65536-91)%256; //9174 num++; if(num == 1) { num = 0; time++; e1 = time/10; e0 = time%10; if(time == 1) { time = 0; e2++; if(e2 == 10) { e2 = 0; e3++; if(e3 == 6) { e3 = 0; e4++; if(e4 == 10) { e4 = 0; e5++; if(e5 == 6) { e5 = 0; e6++; if(e6 == 10) { e6 = 0; e7++; if(e7*10+e6 == 24) { e7=0; e6=0; } } } } } } } } } |
|
相关推荐
4个回答
|
|
if(e6 == 10)
{ e6 = 0; e7++; if(e7*10+e6 == 24) { e7=0; e6=0; } } 这段代码要e6 = 10 才能进入,假设e6 =4,e7=2时是进入不鸟这段代码,也就是e7=0;e6=0;永远都执行不了. |
|
|
|
我想做一个多组秒表,你会不?就像体育跑步用的一样
|
|
|
|
你编的程序我实在是看不懂了,提个建议啊,弄三个变量:小时,分,秒,显示的时候把这三个变量和数码管做个对应就行了,程序看着清楚就不容易出错了~
|
|
|
|
很明显是看了郭大侠的代码,可以翻看几次视频就明白了
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
7 浏览 0 评论
26 浏览 1 评论
基于瑞萨FPB-RA4E2智能床头灯项目——1编译环境搭建与点亮驱动ws2812全彩LED
13 浏览 0 评论
嵌入式学习-飞凌嵌入式ElfBoard ELF 1板卡-LCD显示图片编程示例之介绍mmap
644 浏览 0 评论
《DNESP32S3使用指南-IDF版_V1.6》第二章 常用的C语言知识点
1000 浏览 0 评论
【youyeetoo X1 windows 开发板体验】少儿AI智能STEAM积木平台
11771 浏览 31 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 17:14 , Processed in 0.615715 second(s), Total 76, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号