找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 6570|回復(fù): 6
收起左側(cè)

[求助]一個(gè)按鍵程序

[復(fù)制鏈接]
ID:12195 發(fā)表于 2009-5-7 21:24 | 顯示全部樓層 |閱讀模式

各位朋友能不能幫我用C語(yǔ)言編譯這樣的一個(gè)程序;
     

按K1,延時(shí)一段時(shí)間,數(shù)碼管顯示01。

按K2,延時(shí)一段時(shí)間,數(shù)碼管顯示02

按K3,延時(shí)一段時(shí)間,數(shù)碼管顯示03

按K4,延時(shí)一段時(shí)間,數(shù)碼管顯示04

按K5,延時(shí)一段時(shí)間,數(shù)碼管顯示05

按K6,延時(shí)一段時(shí)間,數(shù)碼管顯示06

按K7,延時(shí)一段時(shí)間,數(shù)碼管顯示07

按K8,延時(shí)一段時(shí)間,數(shù)碼管顯示08

按K9,延時(shí)一段時(shí)間,數(shù)碼管顯示09

按K10,延時(shí)一段時(shí)間,數(shù)碼管顯示10

按K11,延時(shí)一段時(shí)間,數(shù)碼管顯示11

按K12,延時(shí)一段時(shí)間,數(shù)碼管顯示12 
謝謝

回復(fù)

使用道具 舉報(bào)

ID:13782 發(fā)表于 2009-6-4 16:52 | 顯示全部樓層
 那得先看一下硬件圖紙才能再寫(xiě)一下的。另外,這些功能一個(gè)鍵就行了,為什么還要用12個(gè)鍵,在單片機(jī)系統(tǒng)中資源很寶貴的噢。

回復(fù)

使用道具 舉報(bào)

ID:61326 發(fā)表于 2014-5-4 11:30 | 顯示全部樓層
我也來(lái)做做
回復(fù)

使用道具 舉報(bào)

ID:59151 發(fā)表于 2014-5-13 00:48 | 顯示全部樓層
要對(duì)應(yīng)硬件線路才能寫(xiě)呀,要不就是硬件受制于軟件了,不劃算吧?嘿嘿………………程序是不難的
回復(fù)

使用道具 舉報(bào)

ID:48413 發(fā)表于 2014-7-15 21:09 | 顯示全部樓層
回復(fù)

使用道具 舉報(bào)

ID:63778 發(fā)表于 2014-7-16 18:15 | 顯示全部樓層
用矩陣鍵盤(pán)掃描來(lái)做 我的板子是郭天祥的
回復(fù)

使用道具 舉報(bào)

ID:63778 發(fā)表于 2014-7-16 18:15 | 顯示全部樓層
#include<reg52.h>
#define uint unsigned int
#define uchar unsigned char
sbit dula=P2^6;
sbit wela=P2^7;
void delay(uint);
void display(uchar);
void keyscan();
uchar code table[]=
{
        0x3f,0x06,0x5b,0x4f,
        0x66,0x6d,0x7d,0x07,
        0x7f,0x6f,0x77,0x7c,
        0x39,0x5e,0x79,0x71

};
void main()
{       
        dula=1;
        P0=0;
        dula=0;
        wela=1;
        P0=0xc0;
        wela=0;

        while(1)
        {
                keyscan();
               
        }

}
void display(uchar num)       
{
        dula=1;
        P0=table[num];
        dula=0;
        P0=0xff;
}
void delay(uint z)
{
        uint x,y;
        for(x=z;x>0;x--)
                for(y=110;y>0;y--);
}
void keyscan()
{       
        uchar temp ,key;
        P3=0xfe;
        temp=P3;
        temp=temp&0xf0;
        if(temp!=0xf0)
        {
                delay(10);
                temp=P3;
                temp=temp&0xf0;
                if(temp!=0xf0)
                {
                        temp=P3;
                        switch(temp)
                        {
                                case 0xee:
                                                        key=0;
                                                        break;
                                case 0xde:
                                                        key=1;
                                                        break;
                                case 0xbe:
                                                        key=2;
                                                        break;
                                case 0x7e:
                                                        key=3;
                                                        break;
                               
                        }
               
                        while(temp!=0xf0)
                        {
                                temp=P3;
                                temp=temp&0xf0;
                        }
                        display(key);
                }
        }




        P3=0xfd;
        temp=P3;
        temp=temp&0xf0;
        if(temp!=0xf0)
        {
                delay(10);
                temp=P3;
                temp=temp&0xf0;
                if(temp!=0xf0)
                {
                        temp=P3;
                        switch(temp)
                        {
                                case 0xed:
                                                        key=4;
                                                        break;
                                case 0xdd:
                                                        key=5;
                                                        break;
                                case 0xbd:
                                                        key=6;
                                                        break;
                                case 0x7d:
                                                        key=7;
                                                        break;
                               
                        }
               
                        while(temp!=0xf0)
                        {
                                temp=P3;
                                temp=temp&0xf0;
                        }
                        display(key);
                }
        }


        P3=0xfb;
        temp=P3;
        temp=temp&0xf0;
        if(temp!=0xf0)
        {
                delay(10);
                temp=P3;
                temp=temp&0xf0;
                if(temp!=0xf0)
                {
                        temp=P3;
                        switch(temp)
                        {
                                case 0xeb:
                                                        key=8;
                                                        break;
                                case 0xdb:
                                                        key=9;
                                                        break;
                                case 0xbb:
                                                        key=10;
                                                        break;
                                case 0x7b:
                                                        key=11;
                                                        break;
                               
                        }
               
                        while(temp!=0xf0)
                        {
                                temp=P3;
                                temp=temp&0xf0;
                        }
                        display(key);
                }       
        }
               


        P3=0xf7;
        temp=P3;
        temp=temp&0xf0;
        if(temp!=0xf0)
        {
                delay(10);
                temp=P3;
                temp=temp&0xf0;
                if(temp!=0xf0)
                {
                        temp=P3;
                        switch(temp)
                        {
                                case 0xe7:
                                                        key=12;
                                                        break;
                                case 0xd7:
                                                        key=13;
                                                        break;
                                case 0xb7:
                                                        key=14;
                                                        break;
                                case 0x77:
                                                        key=15;
                                                        break;
                               
                        }
               
                        while(temp!=0xf0)
                        {
                                temp=P3;
                                temp=temp&0xf0;
                        }
                        display(key);
                }
        }


}
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表