基于单片机的智能避障遥控小车
void initial_myself() {
TMOD = 0x01;//
TH0 = (65536 - 50) / 256;//微秒
TL0 = (65536 - 50) % 256;
//
TMOD = 0x21;
TH1 = TL1 = 0xfd;// IP }
void initial_interrupt() {
EA = 1;//
定时50SCON = 0x50; 设置波特率9600 = 0x10;//设置串口中断为高优先级开总中断
基于单片机的智能避障遥控小车
ES = 1;// 开串口中断 ET0 = 1;//开定时器0中断? TR0 = 1;//开定时器0 TR1 = 1;// 开定时器1 }
void delay_long(unsigned int time) {
unsigned int i; unsigned int j;
for(i = 0 ; i < time ; i++) {
} }
void go_forward()
for(j = 0; j < 500; j++);
基于单片机的智能避障遥控小车
{
motor_control_1 = 0; motor_control_2 = 1; motor_control_3 = 0; motor_control_4 = 1; }
void stop() {
motor_control_1 = 0; motor_control_2 = 0; motor_control_3 = 0; motor_control_4 = 0; }
void turn_left() {
基于单片机的智能避障遥控小车
int i=5000; for(;i>=0;i--) { if(i) {
motor_control_1 = 0; motor_control_2 = 0; motor_control_3 = 0; motor_control_4 = 1; } else {
motor_control_1 = 0; motor_control_2 = 0; motor_control_3 = 0; motor_control_4 = 0; } }
相关推荐: