天天看點

智能小車c語言程式,用51單片機編寫的智能小車全程前進的C程式

該樓層疑似違規已被系統折疊 隐藏此樓檢視此樓

#include #define Left_moto_pwm P1_6 //接驅動子產品ENA 使能端,輸入PWM信号調節速度

#define Right_moto_pwm P1_7 //接驅動子產品ENB #define Left_1_led P1_0 //四路尋迹子產品接口第一路

#define Left_2_led P1_1 //四路尋迹子產品接口第二路

#define Right_1_led P1_2 //四路尋迹子產品接口第三路

#define Right_2_led P1_3 //四路尋迹子產品接口第四路

#define Left_moto_go {P3_4=0,P3_5=1;} //P3_4 P3_5 接IN1 IN2 當 P3_4=0,P3_5=1; 時左電機前進

#define Left_moto_back {P3_4=1,P3_5=0;} //P3_4 P3_5 接IN1 IN2 當 P3_4=1,P3_5=0; 時左電機後退

#define Right_moto_go {P3_6=0,P3_7=1;} //P3_6 P3_7 接IN1 IN2 當 P3_6=0,P3_7=1; 時右電機前轉

#define Right_moto_back {P3_6=1,P3_7=0;} //P3_6 P3_7 接IN1 IN2 當 P3_6=1,P3_7=0; 時右電機後退 void main(void)

{ Left_moto_pwm =1;

Right_moto_pwm=1; //使能端置1全速前進 while(1)

{ Left_moto_go;

Right_moto_go; }

}

微信:156125701