欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標(biāo)題:
藍(lán)牙遙控小車程序
[打印本頁]
作者:
hgp001
時(shí)間:
2017-4-22 13:00
標(biāo)題:
藍(lán)牙遙控小車程序
#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();
}
}
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1