新聞中心

stc電子表c51程序V2.0

作者: 時(shí)間:2016-11-29 來(lái)源:網(wǎng)絡(luò) 收藏
電路很簡(jiǎn)單我就不畫(huà)了,是stc系列的單片機(jī)做的,顯示部分就是2個(gè)74hc573芯片連到P1口,然后用p3.0控制段選,按鍵的定義程序里有說(shuō)明。很容易就能搭出來(lái),下圖是效果圖,自己用萬(wàn)用板焊的,技術(shù)不行。到處都是飛線呵呵,請(qǐng)大家多多指教


程序的c51語(yǔ)言完整版本的下載地址:http://www.51hei.com/f/biaoc4.rar

本文引用地址:http://butianyuan.cn/article/201611/323265.htm
#include#define uchar unsigned char#define uint unsigned intuchar d0,ss,gs,sf,gf,sm,gm;uchar e1,e2,e3,e4,e5,e6;uchar s1,q1;uchar shi,fen,miao;// 8 4 2 1 8 4 2 1  // h g f e d c b a//效正 累加數(shù)98 跑1320秒 實(shí)際1316//當(dāng)前已走秒數(shù) 乘以 當(dāng)前累加數(shù) 除以除以實(shí)際秒數(shù) 等于 累加數(shù)應(yīng)得值uchar code num[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x80};//0-9 點(diǎn)uchar code wes[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0x7f};//1-8位sbit dua=P3^0;sbit laba=P3^1;sbit a1=P3^2;//時(shí)間設(shè)置sbit a2=P3^3;//鬧鐘設(shè)置sbit a3=P3^4;//按鍵+sbit a4=P3^5;//按鍵-sbit a5=P3^7;//返回 啟動(dòng)鬧鐘void weiduan(uchar z,uchar x); //位段 函數(shù)void chushi();    //初始化函數(shù)void shijian();   //時(shí)間顯示函數(shù)void shjianbata();//測(cè)試時(shí)間函數(shù)void shezhi();    //時(shí)間設(shè)置函數(shù)void naozhong();  //鬧鐘這是函數(shù)void shu();       //時(shí)間最大值限制函數(shù)void delay(uchar d1);//延時(shí)函數(shù)//.....................................................................................void main(){ chushi(); //初始化時(shí)間TH0=(65535-40000)/256;//定時(shí)器裝初值TL0=(65535-40000)%256;ET0=1;//開(kāi)定時(shí)器0中斷TR0=1;//啟動(dòng)定時(shí)器0EA=1; //打開(kāi)總中斷l(xiāng)aba=1;while(1){  shijian(); //調(diào)用時(shí)間顯示函數(shù) 顯示時(shí)間 if(a1==1){if(a2==1){if(a3==1){if(a4==1){ weiduan(1,10);delay(5);weiduan(3,10);delay(5);weiduan(5,10);delay(5); }}}}if(a1==0){delay(100);if(a1==0){shezhi();}}if(a2==0){delay(100);if(a2==0){naozhong();}}//調(diào)用鬧鐘設(shè)置函數(shù)if(a5==0){delay(100);{if(a5==0){while(1){if(q1==0){q1=1;break;}else{q1=0;break;}}while(a5==0);delay(100);}}}if(a2==0){delay(100);if(a2==0){naozhong();}    }if(q1==1){weiduan(6,0);delay(20);if(fen==e2){if(shi==e1){laba=0;}}if(fen!=e2){laba=1;}  }else{laba=1;}}}//.....................................................................................void naozhong(){while(1){   ss=e1/10;gs=e1%10;  sf=e2/10;gf=e2%10;   sm=e3/10;gm=e3%10;delay(10);weiduan(0,ss);delay(10);weiduan(1,gs);delay(10);weiduan(2,sf);delay(10);     weiduan(3,gf);delay(10);weiduan(4,sm);delay(10);weiduan(5,gm);delay(10);if(a1==0){delay(100);if(a1==0){while(a1==0);delay(20);break;}}if(a2==0){delay(100);while(a2==0);delay(20);s1++;}if(s1==3){s1=0;}if(s1==1){weiduan(0,10);delay(5);weiduan(1,10);delay(5);if(a3==0){delay(20);if(a3==0){e1++;}while(a3==0);delay(100);}if(a4==0){delay(20);if(a4==0){e1--;}while(a4==0);delay(100);}}if(s1==2){weiduan(2,10);delay(5);weiduan(3,10);delay(5);if(a3==0){delay(20);if(a3==0){e2++;}while(a3==0);delay(100);}if(a4==0){delay(20);if(a4==0){e2--;}while(a4==0);delay(100);}}if(s1==0){weiduan(4,10);delay(5);weiduan(5,10);delay(5);if(a3==0){delay(20);if(a3==0){e3++;}while(a3==0);delay(100);}if(a4==0){delay(20);if(a4==0){e3--;}while(a4==0);delay(100);}}}}				   
				
            
                
			
							
上一頁(yè) 1 2 下一頁(yè)

關(guān)鍵詞: stc電子表c51程

評(píng)論


技術(shù)專(zhuān)區(qū)

關(guān)閉