| 网站首页 | 业界新闻 | 群组 | 交易 | 人才 | 下载频道 | 博客 | 代码贴 | 编程论坛
共有 218 人关注过本帖
标题:请教一编程
只看楼主 加入收藏
荆世翔
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2018-3-10
结帖率:0
  问题点数:0  回复次数:0   
请教一编程
#include <reg52.h>
#include <intrins.h>
#define uint8 unsigned char
#define uint16 unsigned int
#define shuama P0
sbit dianji11=P1^4;
sbit dianji12=P1^5;
sbit dianji21=P3^4;
sbit dianji22=P3^5;
void UART_init()     /????
{
    PCON=0X80;
    TMOD = 0x20;      //T1????2 8?????
    TH1 = 0xFd;
    TL1 = 0xFd;     //???19200
    TR1 = 1;        //??T1???
    SM0 = 0;
    SM1 = 1;         //??????1  10???   
    REN = 1;        //??????
    ES  = 1;        //??????
    EA = 1;            // ????
}
uint8 num,m;
void  main()         //?????
{
    UART_init();
    while(1)
    {

    }

}

void UART() interrupt 4
{
   
        if(RI)           //????????
    {
        num =SBUF;        //num?????????   
        RI=0;
            if(num==0x01)
    {
        dianji11=1;
        dianji12=0;
        dianji21=1;
        dianji22=0;    }
        if(num==0x02)
    {
        dianji12=1;   
         dianji11=0;
        dianji21=0;
        dianji22=1;
    }
    if(num==0x03)
    {
         dianji11=1;
        dianji12=0;
        dianji21=0;
        dianji22=1;
    }
    if(num==0x04)
    {
         dianji11=0;
        dianji12=1;
        dianji21=1;
        dianji22=0;
    }
        if(num==0x05)
        {
         dianji11=0;
        dianji12=0;
        dianji21=0;
        dianji22=0;
    }

        SBUF=num;
        while(!TI);
        TI=0;   
    }   
}



怎么改可以实现用蓝牙控制,这个是串口控制!
2018-03-10 22:45







关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025811 second(s), 9 queries.
Copyright©2004-2018, BCCN.NET, All Rights Reserved