新聞中心

        EEPW首頁 > 嵌入式系統 > 設計應用 > PIC單片機led燈左移右移

        PIC單片機led燈左移右移

        作者: 時間:2016-11-30 來源:網絡 收藏
        程序介紹:每隔100ms,移動一個燈亮


        本文引用地址:http://www.104case.com/article/201611/323992.htm
        //** Date: Wednesday, November 21, 2012 21:26:32


        #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
        //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)
        {
        //Calculation
        //Calculation:
        // count = 0x01
        FCV_COUNT = 0x01;
        //Loop
        //Loop: While count>0
        while (FCV_COUNT>0)
        {
        //Output
        //Output: count -> PORT C
        trisc = 0x00;
        portc = FCV_COUNT;

        //Delay
        //Delay: 100 ms
        delay_ms(100);

        //Calculation
        //Calculation:
        // count = count<<1
        FCV_COUNT = FCV_COUNT<<1;
        }

        //Calculation
        //Calculation:
        // count = 0x80
        FCV_COUNT = 0x80;
        //Loop
        //Loop: While count>0
        while (FCV_COUNT>0)
        {
        //Output
        //Output: count -> PORT C
        trisc = 0x00;
        portc = FCV_COUNT;

        //Delay
        //Delay: 100 ms
        delay_ms(100);

        //Calculation
        //Calculation:
        // count = count>>1
        FCV_COUNT = FCV_COUNT>>1;
        }

        }

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


        評論


        技術專區

        關閉
        主站蜘蛛池模板: 辰溪县| 余庆县| 东辽县| 河北区| 宣威市| 彭州市| 五台县| 汨罗市| 汝城县| 松桃| 康平县| 彭州市| 简阳市| 崇礼县| 呼图壁县| 贺州市| 云霄县| 安庆市| 枝江市| 台中市| 孟津县| 寿光市| 芮城县| 凤山市| 泰和县| 广平县| 平果县| 漠河县| 六枝特区| 江孜县| 开封市| 南京市| 桃园市| 上虞市| 三都| 高清| 沭阳县| 遂溪县| 马龙县| 红河县| 南溪县|