久久久久久久999_99精品久久精品一区二区爱城_成人欧美一区二区三区在线播放_国产精品日本一区二区不卡视频_国产午夜视频_欧美精品在线观看免费

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 2127|回復: 0
收起左側

藍牙遙控小車程序

[復制鏈接]
ID:191600 發表于 2017-4-22 13:00 | 顯示全部樓層 |閱讀模式
#include<AT89x51.H>
#define A_left_moto_go  {P2_0 = 1,P2_1 = 0;}   //左前輪向前
#define A_left_moto_back {P2_0 = 0,P2_1 = 1;}   //左前輪向后
#define A_left_moto_stop {P2_0 = 0,P2_1 = 0;}    //左前輪停止
#define B_left_moto_go {P2_2 = 1,P2_3 = 0;}  //  
#define B_left_moto_back {P2_2 = 0,P2_3 = 1;} //
#define B_left_moto_stop {P2_2 = 0,P2_3 = 0;}   //

#define A_right_moto_go {P1_0 = 1,P1_1 = 0;}  //右前輪向前
#define A_right_moto_back {P1_0 = 0,P1_1 = 1;}  //右前輪向后
#define A_right_moto_stop {P1_0 = 0,P1_1 = 0;}
#define B_right_moto_go {P1_2 = 1,P1_3 = 0;}  //
#define B_right_moto_back {P1_2 = 0,P1_3 = 1;}
#define B_right_moto_stop {P1_2 = 0,P1_3 = 0;}                    
#define uint    unsigned int                          //??????????
#define uchar   unsigned char                         //??????????
sbit BZ=P3^7;
a=0;
void delay(uchar z)//??????????
{
int i,j;//??????
for(i=10;i>0;i--)
for(j=z;j>0;j--);//???z???j
}

void uart_init()
{
  TMOD = 0x20;
  PCON = 0x00;
  SCON = 0x50;
  TH1 = 0xFd;  //????? 9600
  TL1 = 0xFd;
  TR1 = 1;     //?????1
  ES = 1;      //?????
  EA = 1;      //????
  BZ=1;
}

/************************************************************************/
void run()
{
         A_left_moto_go;
         A_right_moto_go;
         B_left_moto_go;
         B_right_moto_go;
}
void back_run()
{
         A_left_moto_back;
         A_right_moto_back;
         B_left_moto_back;
         B_right_moto_back;
}
void stop_run()
{
         A_left_moto_stop;
         A_right_moto_stop;
         B_left_moto_stop;
         B_right_moto_stop;
}
void left_run()
{
         A_left_moto_back;
         A_right_moto_go;
         B_left_moto_back;
         B_right_moto_go;
}
void right_run()
{
         A_left_moto_go;
         A_right_moto_back;
         B_left_moto_go;
         B_right_moto_back;
}

void uart() interrupt 4
{
if(RI==1)
RI=0;
a=SBUF;
}

void main()
{
//P0=0XFF;
uart_init();
while(1)
{
  if(BZ==0)   stop_run();
  if(a==0x00) stop_run();
  if(a==0x3f) run();
  if(a==0x4f) back_run();
  if(a==0x1f) left_run();
  if(a==0x2f) right_run();
  if(a==0x5f) left_run();
  if(a==0x6f) right_run();
  if(a==0x7f) left_run();
  if(a==0x8f) right_run();

  
}
}
回復

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表
主站蜘蛛池模板: 日韩精品一区二区三区高清免费 | 国产精品久久av | 一区二区三区免费在线观看 | 欧美xxxⅹ性欧美大片 | 亚洲淫视频 | 久久国产精品久久久久 | 欧美涩 | 一区中文字幕 | 亚洲精品日韩一区二区电影 | 亚洲精品9999久久久久 | 久久天堂网 | 日韩免费视频一区二区 | 在线观看中文字幕 | 国产精品久久久久久久午夜 | 一区视频在线免费观看 | 高清一区二区 | 精品九九九 | 成人精品 | 国产精品入口 | 精品久久久久久亚洲综合网站 | 日韩av一区二区在线 | 成年人在线视频 | 成人精品鲁一区一区二区 | 羞羞的视频免费看 | 精品久久国产 | aaa国产大片 | 久久97精品 | 日韩中文字幕 | 亚洲日本欧美 | 黄网站色大毛片 | 日韩三级| 国产精品久久久久国产a级 欧美日本韩国一区二区 | 亚洲www啪成人一区二区麻豆 | 欧美成年黄网站色视频 | 91在线播| 欧美日韩一区在线 | 伦理片97| 玖玖综合在线 | 欧美九九| 亚州一区二区三区 | 国产午夜精品一区二区三区嫩草 |