基于51單片機的5分鐘倒計時程序+仿真
0.png (9.99 KB, 下載次數(shù): 122)
下載附件
2018-12-14 22:09 上傳
0.png (11.91 KB, 下載次數(shù): 111)
下載附件
2018-12-14 22:09 上傳
單片機源程序如下:
- #include<reg51.h>
- unsigned char Seg_CA_Data[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
- unsigned char Seg_CA_Position[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};
- void DelayTime10ms(unsigned int DelayValue);
- void Seg_Display_Second(unsigned char DisData,unsigned char Seg_Number);
- void Seg_Display_Minute(unsigned char DisData,unsigned char Seg_Number);
- void main()
- {
- unsigned char Second =59;
- unsigned char Minute=0x04;
- unsigned char Count=10;
- for(;;)
- {
- while( Count--)
- {
- Seg_Display_Second(Second,2);
- Seg_Display_Minute(Minute,2);
- }
- Count=10;
- if(Second--==0)
- {
- Second=59;
- if(Minute--==0)
- {
- Second=59;
- Minute=4;
- }
- }
- }
- }
- void DelayTime10ms(unsigned int DelayValue)
- {
- unsigned int a,b;
- for(a=0;a<DelayValue;a++)
- for(b=0;b<1828;b++);
- }
- void Seg_Display_Second(unsigned char DisData,unsigned char Seg_Number)
- {
- unsigned char i=0;
- for(i=0;i<Seg_Number;i++)
- {
- P2=Seg_CA_Position[i];
- P0=Seg_CA_Data[DisData%10];
- DisData=DisData/10;
- DelayTime10ms(1);
- }
- }
- void Seg_Display_Minute(unsigned char DisData,unsigned char Seg_Number)
- {
- unsigned char i=0;
- P2=Seg_CA_Position[2];
- P0=0xbf;
- DelayTime10ms(1);
- for(i=3;i<Seg_Number+3;i++)
- {
- P2=Seg_CA_Position[i];
- P0=Seg_CA_Data[DisData%10];
- DisData=DisData/10;
- DelayTime10ms(1);
- }
- }
復制代碼
所有資料51hei提供下載:
5分鐘 倒計時.zip
(24.93 KB, 下載次數(shù): 167)
2018-12-14 15:49 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
|