新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > PIC單片機多路開關程序

        PIC單片機多路開關程序

        作者: 時間:2016-11-30 來源:網絡 收藏
        程序介紹:使用同一個IO口進行設置,高字節為按鍵,低字節為燈,流程中嵌入關系式變化:

        FCV_COUNT = FCV_COUNT>>4;
        FCV_COUNT = FCV_COUNT & 0x0f;

        //** Date: Wednesday, November 21, 2012 20:50:00
        //本程序版權所有: 51hei.com
        #define MX_PIC
        //Defines for microcontroller
        #define P16F690
        #define MX_EE
        #define MX_EE_SIZE 256
        #define MX_SPI
        #define MX_SPI_BCB
        #define MX_SPI_SDI 4
        #define MX_SPI_SDO 7
        #define MX_SPI_SCK 6
        #define MX_UART
        #define MX_UART_B
        #define MX_UART_TX 7
        #define MX_UART_RX 5
        #define MX_I2C
        #define MX_MI2C
        #define MX_I2C_B
        #define MX_I2C_SDA 4
        #define MX_I2C_SCL 6
        #define MX_PWM
        #define MX_PWM_CNT 1
        #define MX_PWM_TRIS1 trisc
        #define MX_PWM_1 5

        本文引用地址:http://www.104case.com/article/201611/323979.htm

        //Functions
        #define MX_CLK_SPEED 19660800
        #ifdef _BOOSTC
        #include
        #endif
        #ifdef HI_TECH_C
        #include
        #endif
        //Configurationdata
        //Internal functions
        #include "F:Program FilesMatrix MultimediaFlowcode V4FCDinternals.h"
        //Macro function declarations

        //Variable declarations
        char FCV_COUNT;
        //Macro implementations
        void main()
        {

        //Initialisation
        ansel = 0;
        anselh = 0;

        //Interrupt initialisation code
        option_reg = 0xC0;

        //Loop
        //Loop: While 1
        while (1)
        {
        //Input
        //Input: PORT C -> count
        trisc = trisc | 0xff;
        FCV_COUNT = portc;

        //Calculation
        //Calculation:
        // count = count>>4
        // count = count AND 0x0f
        FCV_COUNT = FCV_COUNT>>4;
        FCV_COUNT = FCV_COUNT & 0x0f;
        //Output
        //Output: count -> PORT C
        trisc = 0x00;
        portc = FCV_COUNT;

        }

        mainendloop: goto mainendloop;
        }
        void MX_INTERRUPT_MACRO(void)
        {
        }


        關鍵詞: PIC單片機多路開

        評論


        技術專區

        關閉
        主站蜘蛛池模板: 旬阳县| 海原县| 牟定县| 博乐市| 法库县| 阿巴嘎旗| 龙井市| 邵武市| 沁水县| 金坛市| 昭通市| 四会市| 屯留县| 株洲市| 阿合奇县| 华安县| 肥西县| 中宁县| 正定县| 林西县| 义乌市| 梁山县| 东安县| 弥勒县| 阿勒泰市| 哈巴河县| 进贤县| 阿拉善右旗| 永德县| 小金县| 田东县| 宿迁市| 杭锦旗| 鄂托克前旗| 双鸭山市| 和政县| 呼玛县| 工布江达县| 铁岭县| 南召县| 万山特区|