欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 兩個獨立按鍵單片機程序 控制靜態數碼管數字增加或減少 [打印本頁]

作者: kscheang    時間: 2021-1-14 01:21
標題: 兩個獨立按鍵單片機程序 控制靜態數碼管數字增加或減少
//靜態數碼管, 按下K1增加到F, 按下K2減少到0


#include "reg52.h"                        
typedef unsigned int u16;         
typedef unsigned char u8;
sbit K1=P1^0;
sbit K2=P1^2;
unsigned int i=0;
signed int j=0;
u8 code smgduan[17]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,
                     0x7f,0x6f,0x77,0x7c,0x39,0x5e,0x79,0x71};
void delay(u16 i)
{
while(i--);        
}
void keypush1()
{
if (K1==0)
{
  delay(1000);
  if (K1==0)
  {
   j++;
  }
while(!K1);
}
}
void keypush2()
{
if (K2==0)
{
  delay(1000);
  if (K2==0)
  {
   j--;
  }
while(!K2);
}
}
void DigDisplay()
{
    P0=~smgduan[j];
}
void main()
{        
while(1)
    {        
  keypush1();
  if (j>15)
  {
   j=15;
  }         
  keypush2();
  if (j<0)
  {
   j=0;
  }         
     DigDisplay();
}               
}





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