日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]此程序是根據(jù)自己的單片機(jī)板子寫的,四位共陽數(shù)碼管。k1-k4是板子上的4個(gè)鍵 用來進(jìn)行二進(jìn)制輸入,因?yàn)榘存I只有按下和沒有按下兩種狀態(tài),十進(jìn)制的數(shù)值就顯示在數(shù)碼管上.#include <reg51.h> #define uchar unsigned c

此程序是根據(jù)自己的單片機(jī)板子寫的,四位共陽數(shù)碼管。

k1-k4是板子上的4個(gè)鍵 用來進(jìn)行二進(jìn)制輸入,因?yàn)榘存I只有按下和沒有按下兩種狀態(tài),

十進(jìn)制的數(shù)值就顯示在數(shù)碼管上.

#include <reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code smg[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
uchar data yy[]={0xff,0xfe,0xfc,0xf8,0xf0,0xfe0,0xc0,0x80,0x00};
uint a;

sbit K1=P3^0;
sbit K2=P3^1;
sbit K3=P3^2;
sbit K4=P3^3;

sbit P20=P2^0;
sbit P22=P2^2;

sbit wx1=P0^0;
sbit wx2=P0^1;
sbit wx3=P0^2;
sbit wx4=P0^3;

void delayms(uint a)
{
uchar i,j;
for(i=a;i>0;i--)
for(j=110;j>0;j--);
}

void main()
{
while(1)
{
{
if(K1==0)   
 {
   wx1=1;
   P1=smg[0];
   wx2=0;wx3=0;wx4=0;
   P2=yy[0];
 }


if(K2==0)    
 {
   wx1=1;
   P1=smg[1];
   wx2=0;wx3=0;wx4=0;
   P2=yy[1];
 }


if(K3==0)    
 {
   wx1=1;
   P1=smg[2];
   wx2=0;wx3=0;wx4=0;
   P2=yy[2];
 }

if(K4==0)    
 {
   wx1=1;
   P1=smg[3];
   wx2=0;wx3=0;wx4=0;
   P2=yy[3];
 }

if(K1==0&K2==0)   
{
   wx1=1;
   P1=smg[4];
   delayms(10);
   wx1=0;wx2=0;wx3=0;wx4=0;
   P2=yy[4];
   delayms(10);
 }

if(K1==0&K3==0)    
 {
   wx1=1;
   P1=smg[5];
   delayms(10);
   wx1=0;wx2=0;wx3=0;wx4=0;
   P2=yy[5];
   delayms(10);
  }

if(K1==0&K4==0)   
  {
   wx1=1;
   P1=smg[6];
   delayms(10);
   wx1=0;wx2=0;wx3=0;wx4=0;
   P2=yy[6];
   delayms(10);
  }

if(K2==0&K3==0)   
  {
   wx1=1;
   P1=smg[7];
   delayms(10);
   wx1=0;wx2=0;wx3=0;wx4=0;
   P2=yy[7];
   delayms(10);
  }

if(K2==0&K4==0)  
   {
   P20=1;P22=1;
   wx1=1;
   P1=smg[8];
   delayms(10);
   wx1=0;wx2=0;wx3=0;wx4=0;
   P2=yy[8];
   delayms(10);
  }

if(K3==0&K4==0)   
  {
   wx1=1;
   P1=smg[9];
   delayms(10);
   wx1=0;wx2=0;wx3=0;wx4=0;
   P2=yy[8];
   delayms(10);
}
}
P2=0xff;
}
}
 

 

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉