中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. 新聞中心

        EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 51單片機按鍵搶答器程序

        51單片機按鍵搶答器程序

        作者: 時間:2016-12-01 來源:網絡 收藏

        /**********************************************
        函數(shù)名稱:write_data(uchar date)
        函數(shù)功能:寫數(shù)據(jù)
        函數(shù)調用:delay_ms(uint num)
        輸入?yún)?shù):數(shù)據(jù)
        輸出參數(shù):
        版權信息:
        時間版本: V1.0
        ***********************************************/
        void LCD_w_data(uchar dat)
        {
        LCD_RS=1;
        LCD_RW=0;
        LCD_DATA=dat;
        delay_ms(5);
        LCD_EN=1;
        delay_ms(5);
        LCD_EN=0;
        }
        /**********************************************
        函數(shù)名稱:
        函數(shù)功能:LCD_init()
        函數(shù)調用:LCD_w_com()
        輸入?yún)?shù):
        輸出參數(shù):
        版權信息:
        時間版本: V1.0
        ***********************************************/
        void LCD_init()
        {
        LCD_EN=0;
        LCD_w_com(0x38);//8線2行5X7字符模式
        LCD_w_com(0x0c);//顯示開,光標不顯示,光標不閃爍
        LCD_w_com(0x06);//光標右移,文字不移動
        LCD_w_com(0x01);//清除顯示,光標復位
        }
        /**********************************************
        函數(shù)名稱: LCD_disp_cher(uchar x,uchar y,uchar *p)
        函數(shù)功能: 指定位置顯示字符串
        函數(shù)調用: LCD_w_com(),LCD_w_data()
        輸入?yún)?shù): x,y坐標,字符串指針數(shù)組
        輸出參數(shù):
        版權信息:
        時間版本: V1.0
        備注: x為列,x<16,y為行,y<2. 字符串長+x不大于16.
        ***********************************************/
        void LCD_disp_cher(uchar x,uchar y,uchar *p)
        {
        if(y==1)
        {
        LCD_w_com(0x80+x);
        while(*p)
        {
        LCD_w_data(*p);
        p++;
        }
        }
        if(y==2)
        {
        LCD_w_com(0x80+0x40+x);
        while(*p)
        {
        LCD_w_data(*p);
        p++;
        }
        }
        }
        #endif//end LCD1602.H

        本文引用地址:http://www.antipu.com.cn/article/201612/324577.htm


        #ifndef _interrupt_H_
        #define _interrupt_H_
        #define uint unsigned int
        #define uchar unsigned char
        uint sec=10;
        sbit sb=P1^0;
        sbit si=P1^1;
        void interrupts_init()
        {
        EA=1; //開總中斷
        ET0=1; // T0(定時中斷0) 的溢出中斷允許位
        TR0=1; //0的運行控制位
        TMOD=0x1; //16位定時器
        TH0=(65536-50000)/255;
        TL0=(65536-50000)%255;
        }
        void ghjfgf() interrupt 1
        {
        uint subtle;
        TH0=(65536-50000)/255;
        TL0=(65536-50000)%255;
        subtle++;
        if(subtle==20)
        {
        subtle=0;
        sec--;
        }
        }
        #endif

        #ifndef _chiclet_keyboard_H_
        #define _chiclet_keyboard_H_
        sbit S1=P3^4; //獨立按鍵S1~S4
        sbit S2=P3^5;
        sbit S3=P3^6;
        sbit S4=P3^7; //用復位鍵退出這樣節(jié)省按鍵
        void delay(uint ms) //延時
        {
        uchar mus;
        for(ms; ms>0; ms--)
        for(mus=110; mus>0; mus--);
        }
        uint chiclet_keyboard_() //按鍵檢測子程序有返回值用于退出該子程序
        {
        uchar dsa[10]; //用于儲存顯示的數(shù)組
        while(1) //檢測死循環(huán),直至檢測道按鍵或時間到sec=0;
        {
        if(S1==0)
        {
        delay(5);
        if(S1==0)
        {
        LCD_disp_cher(0,1," S1 "); //顯示先按的按鍵
        return 0;
        }
        }
        if(S2==0)
        {
        delay(5);
        if(S2==0)
        {
        LCD_disp_cher(0,1," S2 "); //顯示先按的按鍵
        return 0;
        }
        }
        if(S3==0)
        {
        delay(5);
        if(S3==0)
        {
        LCD_disp_cher(0,1," S3 "); //顯示先按的按鍵
        return 0;
        }
        }
        if(S4==0)
        {
        delay(5);
        if(S4==0)
        {
        LCD_disp_cher(0,1," S4 "); //顯示先按的按鍵
        return 0;
        }
        }
        if(sec==0)
        {
        LCD_disp_cher(0,1," over time ");
        return 0;
        }
        sprintf(dsa," time %d ",sec); //顯示時間
        LCD_disp_cher(0,1,dsa);
        }
        }
        #endif


        上一頁 1 2 下一頁

        評論


        技術專區(qū)

        關閉