docx

Hardware connection of obstacle avoidance car

  • 2014-10-27
  • 11.35KB
  • Points it Requires : 2

/**************************************************************************** Hardware connection **********************************************************************/ #include #include  #define Sevro_moto_pwm P2_7 //Connect to the servo signal terminal to input PWM signal to adjust the speed#define ECHO P2_4 //Ultrasonic interface definition#define TRIG P2_5 //Ultrasonic interface definition#define Left_moto_go {P1_0=1,P1_1=0,P1_2=1,P1_3=0;} //The two motors on the left go forward#define Left_moto_back {P1_0=0,P1_1=1,P1_2=0,P1_3=1;} //The two motors on the left turn backward#define Left_moto_Stop {P1_0=0,P1_1=0,P1_2=0,P1_3=0;} //The two motors on the left stop#define Right_moto_go {P1_4=1,P1_5=0,P1_6=1,P1_7=0;} //The two motors on the right go forward#define Right_moto_back {P1_4=0,P1_5=1,P1_6=0,P1_7=1;} //The two motors on the right go forward#define Right_moto_Stop {P1_4=0,P1_5=0,P1_6=0,P1_7=0;} //The two motors on the right stopunsigned char const discode[] ={ 0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90,0xBF,0xff/*-*/}; unsigned char const positon[3]={ 0xfe,0xfd,0xfb}; unsigned char disbuff[4] ={ 0,0,0,0,}; unsigned char posit=0; unsigned char pwm_val_left = 0;//variable definition unsigned char push_val_left =14;//Servo returns to center, generating about 1.5MS signal unsigned long S=0; unsigned long S1=0; unsigned long S2=0; unsigned long S3=0; unsigned long S4=0; unsigned int time=0; //time variable unsigned int timer=0; //delay reference variable unsigned char timer1=0; //scan time variable/********************************************************************/ void delay(unsigned int k) //delay function { unsigned int x,y; for(x=0;x

unfold

You Might Like

Uploader
11521234
 

Recommended ContentMore

Popular Components

Just Take a LookMore

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
×