⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 万年历wmz.txt

📁 单片机写的程序都含有Protues仿真结果
💻 TXT
字号:
#include<REG51.H>
#define	uchar unsigned char
#define	uint unsigned int
uchar tcount,count=0,second=0,minute=0,hour=12;
uint a=0,b=0,c=0;
uchar  dispbuf[6];
uchar code led[6][10]={{0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59},
					   {0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49},
					   {0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39},
					   {0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29},
					   {0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19},
					   {0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09}};
sbit key1=P3^5;
sbit key2=P3^4;
sbit key3=P3^3;


void delay(uint k)
{ uint i,j;
for(i=0;i<k;i++)
   {for(j=0;j<256;j++)
        {;}
   }
}

void light()
{    dispbuf[5]=second%10;
 	 dispbuf[4]=second/10;
	 dispbuf[3]=minute%10;
 	 dispbuf[2]=minute/10;
	 dispbuf[1]=hour%10;
 	 dispbuf[0]=hour/10;
	 for(b=0;b<6;b++)
	 {
	 P1=led[b][dispbuf[b]];
	 delay(1);
	 }
}

void key(void)
   {if(key1==0)
	{delay(10);
  	if(key1)
   		{ while(key1)
		   {second++;
   		   if(second==60)
		      {second=0;}
		  
		  delay(10);
		  }
   	 	}	
  	 }
  

  if(key2==0)
	{delay(10);
  	if(key2==0)
   		{ while(key2==0)
		   {minute++;
   		   if(minute==60)
		      {minute=0;}
		  while(key2==0);
		  }
   	 	}	
  	 }
  
   if(key3==0)
	{delay(10);
	  if(key3==0)
	   {while(key3==0)
	  { hour++;
	    if(hour==24)
	    {hour=0;}
		while(key3==0);
	   }
   	  }
	}	
  	 
   }








void main(void)  
{ 
  TMOD=0x01; 
  TH0=(65536-10000)/256; 
  TL0=(65536-10000)%256; 
  TR0=1; 
  ET0=1;
   EA=1;
   while(1)
   	{  light();
	    key();
	}  
}

void t0(void) interrupt 1 using 0
{ TH0=(65536-10000)/256; 
  TL0=(65536-10000)%256;

   tcount++;
  if(tcount==100)
      {tcount=0;
   	   second++;
       if(second==60)
  	     {second=0;
	      minute++;
	     if(minute==60)
	        {minute=0;
	        hour++;
	        if(hour==24)
	           {hour=0;}
			 }
	      }
        }


 
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -