• 红外模块


    遥控器主要是通过解码来控制红外模块,从而完成小车的行走
    #include "apue.h"
    #include "uart.h"
     
    void main()
    {
        TMOD = 0x20;    // timer1, auto-load
        TH1 = TL1 = 0xFF;
        PCON = 0x80;    // 57600bps on 11.0592M
        SCON = 0x50;    // UART, REN
        IE = 0x91;      // EA, ES, EX0
        TR1 = 1;        // start
     
        while(1);
    }
     
    void int0_IR() interrupt 0
    {
        size_t lowTime, highTime;
        EX0 = 0;
        memset(UARTBuf, 0, SLEN);
        /* detect leader code pluse */
        TH2 = TL2 = 0;          // Clear timer
        TR2 = 1;                // run timer
        while(IR == 0);         // until MCU detect high level
        TR2 = 0;                // stop timer
        UARTBuf[0] = TH2;       // store timer value
        UARTBuf[1] = TL2;
     
        TH2 = TL2 = 0;
        TR2 = 1;
        while(IR == 1);
        TR2 =0;
        UARTBuf[2] = TH2;
        UARTBuf[3] = TL2;
        UARTBuf[SLEN - 1] = 0x7e;   // end of data
        UARTSend();         // send data to PC over RS232
        delayms(1000);          // delay 1 second
        EX0 = 1;
    }
    }
  • 相关阅读:
    OutputStream (字节流写出)
    Reader(字符流读取)
    InputStream (字节流读取)
    File
    IO简介
    BigDecimal
    SimpleDateFormat
    Date和Calendar
    包装类
    本地与远程对应分支,本地建立分支,修改代码, 上传到远程对应的分支
  • 原文地址:https://www.cnblogs.com/yuelingzhi/p/2266745.html
Copyright © 2020-2023  润新知