欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
超級省電的時鐘制作 最省電時可達3mA [修正BUG]
[打印本頁]
作者:
51hei麗人
時間:
2016-6-21 01:00
標題:
超級省電的時鐘制作 最省電時可達3mA [修正BUG]
最近終于有時間發圖片了:
樣子:
顯示月份:
省電模式:
背面走線圖
數碼管底部暗藏IC:
/***********************************************************************
作者:TZR
版本:CK3148 (ver2.0)
功能: 1 顯示時間
2 顯示日期
3 計算年份
4 鬧鐘功能
5 超小體積設計(電池最大……)
6 整點報時
7(重點改進點)超省電設計,正常工作電流在9~12mA之間,最省電時電流可達3mA!鬧鐘鳴響時電流在15mA~18mA左右。
8.增加省電模式,模式下耗電<3.3mA,數碼管不顯示,走時仍然繼續,鬧鐘,整點報時仍然運行。(鬧鐘會中斷省電模式)
日志:V1:實現走時功能,程序整體不穩定,鬧鐘和整點報時功能不正常。
V1.2:修正鬧鐘和整點報時BUG,修正出現“0月0日的”BUG,修正年份顯
V2:改進了程序,作品變得相當省電,耗電量相比之前下降一半,最省電時可達3mA.
V2.2:增加省電模式。修正程序穩定性差,整點報時不兼容“省電模式”的問題。
省電原理:LED顯示屏低頻閃爍,閃爍期間單片機進入空閑模式,使用定時器中斷喚醒單片機,并產生時鐘。
***************************************************************************/
#include <stc12c2052ad.h>
unsigned char hour;
unsigned char min;
unsigned char sec;
unsigned char st;
unsigned char t;
unsigned char alh;
unsigned char alm;
unsigned char yearH;
unsigned char yearL;
unsigned char month;
unsigned char beepc;
unsigned char day;
unsigned char mo;
unsigned bm[12]={1,0,1,0,1,0,1,1,0,1,0,1};
bit am;
sbit mode=P1^7;
sbit chan=P1^6;
sbit beep=P3^7;
sbit v4=P1^5;
sbit c=P1^4;
sbit b=P1^3;
sbit v3=P1^2;
sbit v2=P1^1;
sbit d=P1^0;
sbit e=P3^0;
sbit f=P3^1;
sbit h=P3^2;
sbit g=P3^3;
sbit a=P3^4;
sbit v1=P3^5;
#define close v1=0;v2=0;v3=0;v4=0;
#define led0 a=1;b=1;c=1;d=1;e=1;f=1;g=1;h=1;
#define num0 a=1;b=0;c=0;d=0;e=0;f=0;g=0;
#define num1 a=1;b=1;c=1;e=1;f=1;d=0;g=0;
#define num2 f=0;e=0;d=0;c=0;a=0;
#define num3 g=0;f=0;d=0;c=0;a=0;
#define num4 g=0;d=0;b=0;a=0;
#define num5 g=0;f=0;c=0;b=0;a=0;
#define num6 c=0;b=0;e=0;f=0;g=0;a=0;
#define num7 c=0;d=0;g=0;
#define num8 a=0;b=0;c=0;d=0;e=0;f=0;g=0;
#define num9 a=0;b=0;c=0;d=0;f=0;g=0;
//CLKS0=1;
void delay (unsigned int a){
unsigned int i;
while(--a >= 0){
for(i = 0; i < 300; i++);
}
}
void paint(unsigned char i){
if(i==0){num0;}
if(i==1){num1;}
if(i==2){num2;}
if(i==3){num3;}
if(i==4){num4;}
if(i==5){num5;}
if(i==6){num6;}
if(i==7){num7;}
if(i==8){num8;}
if(i==9){num9;}
}
void main (void){
P3M0=0x00;
P3M1=0x80;
mode=0;
beep=0;
beepc=0;
chan=0;
mo=0;
EA=1;
ET0=1;
st=0;
close;
led0;
hour=11;
min=59;
alh=12;
alm=00;
sec=59;
TH0=0x00;
TL0=0x00;
TR0=1;
t=1;
am=1;
yearH=20;
yearL=11;
month=4;
day=23;
while(1){
if(mo==0){
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
if(chan==1){
delay(20);
if(chan==1){
beep=0;
beepc=0;
while(chan==1);
}
}
if(sec%10==8 || sec%10==9){
led0;
paint(day%10);//0001
close;
v1=1;
delay(t);
led0;
paint(day/10);//0010
close;
v2=1;
delay(t);
led0;
paint(month%10);//0100
h=0;
close;
v3=1;
delay(t);
led0;
paint(month/10);//1000
close;
v4=1;
delay(t);
}else{
led0;
paint(min%10);//0001
close;
v1=1;
delay(t);
led0;
paint(min/10);//0010
close;
v2=1;
delay(t);
led0;
paint(hour%10);//0100
h=sec%2;
close;
v3=1;
delay(t);
led0;
paint(hour/10);//1000
close;
v4=1;
delay(t);
}
}else if(mo==1){
if(st<50){
led0;
paint(hour/10);//1000
close;
v4=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
hour+=10;
if(hour>23){
hour=0;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==2){
if(st<50){
led0;
paint(hour%10);//1000
close;
v3=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
hour+=1;
if(hour%10==0){
hour-=10;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==3){
if(st<50){
led0;
paint(min/10);//1000
close;
v2=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
min+=10;
if(min>59){
min=0;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==4){
if(st<50){
led0;
paint(min%10);//1000
close;
v1=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
min+=1;
if(min%10==0){
min-=10;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==5){
if(st<50){
led0;
paint(month/10);//1000
close;
v2=1;
delay(t);
led0;
paint(month%10);//1000
close;
v1=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
month+=1;
if(month==13){
month=1;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==6){
if(st<50){
led0;
paint(day/10);//1000
close;
v2=1;
delay(t);
led0;
paint(day%10);//1000
close;
v1=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
day+=1;
if(day==32){
day=1;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==7){
if(st<50){
led0;
paint(yearL%10);//0001
close;
v1=1;
delay(t);
led0;
paint(yearL/10);//0010
close;
v2=1;
delay(t);
led0;
paint(yearH%10);//0100
h=0;
close;
v3=1;
delay(t);
led0;
paint(yearH/10);//1000
close;
v4=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
yearL+=1;
if(yearL>=30){
yearL=11;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==8){
if(st<50){
led0;
paint(alh/10);//1000
close;
v4=1;
delay(t);
led0;
paint(alh%10);//1000
close;
v3=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
alh+=1;
if(alh>23){
alh=0;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo++;
}
while(mode==1);
}
}else if(mo==9){
if(st<50){
led0;
paint(alm/10);//1000
close;
v2=1;
delay(t);
led0;
paint(alm%10);//1000
close;
v1=1;
delay(t);
}
if(chan==1){
delay(20);
if(chan==1){
alm+=1;
am=1;
if(alm>=60){
alm=0;
}
while(chan==1);
}
}
if(mode==1){
delay(20);
if(mode==1){
mo=0;
}
while(mode==1);
}
}
}
}
void t0 (void) interrupt 1 {
st++;
if(st>99){
st=0;
sec++;
if(beep==1){
beepc--;
if(beepc<=0){
beep=0;
}
}
}
if(sec>59){
sec=0;
min++;
if(min==alm && hour==alh && am==1){
beep=1;
beepc=50;
}
}
if(min>59){
min=0;
hour++;
beep=1;//整點報時
beepc=1;
}
if(hour>23){
hour=0;
day++;
if(month==2){
if(yearL%4==0){
if(day==30){
day=0;
month++;
}
}else{
if(day==29){
day=0;
month++;
}
}
}else if(bm[month]==0){
if(day==31){
day=0;
month++;
if(month==13){
month=1;
yearL++;
}
}
}else if(bm[month]==1){
if(day==32){
day=0;
month++;
if(month==13){
month=1;
yearL++;
}
}
}
}
TH0=0x6c;/*7a9c*/
TL0=0xc2;
}
復制代碼
作者:
stxlpeng
時間:
2016-6-22 09:33
能把原理圖發上了么
作者:
雙贏電子
時間:
2016-8-5 11:53
謝謝分享
作者:
houniao
時間:
2019-7-25 09:44
能把原理圖發上了
作者:
jwjjwj123
時間:
2025-3-31 22:36
這個沒幾個小時就沒電了.
作者:
powerdruy
時間:
2025-4-1 13:27
3ma很費電了,省電就不能用數碼管,只能用斷碼液晶
作者:
fj51hei
時間:
2025-4-1 14:02
powerdruy 發表于 2025-4-1 13:27
3ma很費電了,省電就不能用數碼管,只能用斷碼液晶
數碼管3mA人家已經很認真了,但對紐扣電池確是電老虎,呵呵!
歡迎光臨 (http://www.raoushi.com/bbs/)
Powered by Discuz! X3.1