標(biāo)題: 單片機(jī)數(shù)碼管定時(shí)打鈴Proteus仿真程序 [打印本頁]

作者: 2468777301    時(shí)間: 2020-11-24 09:34
標(biāo)題: 單片機(jī)數(shù)碼管定時(shí)打鈴Proteus仿真程序


單片機(jī)源程序如下:
#include <reg52.h>
#include <intrins.h>
#define uchar  unsigned char
#define uint   unsigned int
//共陽極數(shù)碼管段碼
uchar code SEG7[]={/*0,1,2,3,4,5,6,7,8,9,*/0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,};
uchar s=5;//設(shè)置時(shí)間
uchar sx=5; //顯示時(shí)間
uchar run;//開始
uchar num[4];
uchar num1;
uchar num2;
//數(shù)碼管位碼端口
sbit      P30=P3^0;
sbit      P31=P3^1;
//按鍵端口定義
sbit      P32=P3^2;
sbit      P33=P3^3;
sbit      P34=P3^4;
sbit      P35=P3^5;
sbit      P36=P3^6;
//延時(shí)函數(shù)ms
void delayms(uint t)
{
   uint i,j;
   for(i=0;i<t;i++)
     for(j=0;j<120;j++);
}
//數(shù)碼管顯示
void dis()
{
//------------------  
//顯示
  P0=SEG7[sx%100/10];
  P30=1;delayms(2);P30=0;
//顯示
  P0=SEG7[sx%10];
  P31=1;delayms(2);P31=0;
//------------------  
}
//顯示控制
void key()
{  
  //復(fù)位
  if(P32==0){sx=s;run=0;P2=0XFF;}
  //停止
  if(P33==0){run=0;P2=0XFF;}
  //開始  
  if(P34==0){if(sx>0)run=1;}
   if(run==0)
   {
   //加1
   if(P35==0){s=s+1;sx=s;while(P35==0);}  
   //減1
   if(P36==0){s=s-1;sx=s;while(P36==0);}
   }  
}


全部資料51hei下載地址:
數(shù)碼管定時(shí)打鈴.rar (52.48 KB, 下載次數(shù): 32)





歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1