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

標題: 基于AT89C51單片機的矩陣鍵盤控制數碼管Proteus仿真程序 [打印本頁]

作者: J1245622552    時間: 2021-11-24 12:17
標題: 基于AT89C51單片機的矩陣鍵盤控制數碼管Proteus仿真程序
仿真原理圖如下(proteus仿真工程文件可到本帖附件中下載)


單片機源程序如下:
#include<reg51.h>
#define uchar unsigned char
#define uint unsigned int
uchar code table[]={
0x3f,0x06,0x5b,0x4f,
0x66,0x6d,0x7d,0x07,
0x7f,0x6f,0x77,0x7c,
0x39,0x5e,0x79,0x71,0x00};//0-f-最后一個空
uchar j=1;
sbit p37=P3^7;
void delay(uint z)
{
    uint x,y;
    for(x=z;x>0;x--)
    for(y=110;y>0;y--);
}
void display(uchar shu)
{   
   
    P1=table[shu];
    delay(5);
}
uchar keyscan()
{
    uchar temp,num;
    P2=0xfe;
    temp=P2;
    temp=temp&0xf0;
    if(temp!=0xf0)
    {
        p37=0;
        delay(5);
        temp=P2;
        temp=temp&0xf0;
        while(temp!=0xf0)
        {
            temp=P2;
            switch(temp)
            {
                case 0xee:num=1;break;
                case 0xde:num=2;break;
                case 0xbe:num=3;break;
default:break;
            }
            while(temp!=0xf0)//**********松手檢測 松手后顯示
            {  
                j=0;
                temp=P2;
                temp=temp&0xf0;
             }
          }
     }p37=1;
   P2=0xfd;
   temp=P2;
    temp=temp&0xf0;
    if(temp!=0xf0)
    {
        p37=0;
        delay(5);
        temp=P2;
        temp=temp&0xf0;
        while(temp!=0xf0)
        {
            temp=P2;
            switch(temp)
            {
                case 0xed:num=4;break;
                case 0xdd:num=5;break;
                case 0xbd:num=6;break;  
            }
            while(temp!=0xf0)
            {
                j=0;
                temp=P2;
                temp=temp&0xf0;
             }
        }
    }p37=1;
    P2=0xfb;
   temp=P2;
    temp=temp&0xf0;
    if(temp!=0xf0)
    {
        p37=0;
        delay(5);
        temp=P2;
        temp=temp&0xf0;
        while(temp!=0xf0)
        {
            temp=P2;
            switch(temp)
            {
                case 0xeb:num=7;break;
                case 0xdb:num=8;break;
                case 0xbb:num=9;break;  
            }
            while(temp!=0xf0)
            {   
                j=0;
                temp=P2;
                temp=temp&0xf0;
            }
         }
    }p37=1;
    P2=0xf7;
    temp=P2;
    temp=temp&0xf0;
    if(temp!=0xf0)
    {
        p37=0;
        delay(5);
        temp=P2;
        temp=temp&0xf0;
        while(temp!=0xf0)
        {
            temp=P2;
            switch(temp)
            {
                case 0xe7:num=16;break;
                case 0xd7:num=0;break;
                case 0xb7:num=16;break;
            }
            while(temp!=0xf0)
            {
                j=0;
                temp=P2;
                temp=temp&0xf0;
            }
         }
        }p37=1;
    //if(j==1)num=16;
    return num;
}
void main()
{
    p37=1;
    while(1)
    {     
    display(keyscan());
        //display(7);
    }
}

仿真.7z (117.53 KB, 下載次數: 72)
視頻.7z (6.02 MB, 下載次數: 14)





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