You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
800 B
32 lines
800 B
#ifndef __MOTOR_H |
|
#define __MOTOR_H |
|
#include "sys.h" |
|
|
|
|
|
#define ENA PBout(0)//电机驱动 |
|
#define ENB PBout(5) |
|
|
|
#define IN1 PBout(12) |
|
#define IN2 PBout(13) |
|
#define IN3 PBout(14) |
|
#define IN4 PBout(15) |
|
|
|
|
|
#define Right_moto_go {IN3=0,IN4=1;} //右电机向前走 |
|
#define Right_moto_back {IN3=1,IN4=0;} //右边电机向后转 |
|
#define Left_moto_Stop {ENA=0;} //左边电机停转 |
|
#define Left_moto_go {IN1=0,IN2=1;} //左边电机向前走 |
|
#define Left_moto_back {IN1=1,IN2=0;} //左边电机向后走 |
|
#define Right_moto_Stop {ENB=0;} //右边电机停转 |
|
|
|
void motor_Init(void);//电机IO口初始化 |
|
void PWM_init(void);//电机速度初始化 |
|
|
|
void run(void);//前进 |
|
void backrun(void);//后退 |
|
void leftrun(void);//左转 |
|
void rightrun(void);//右转 |
|
void stop(void);//停止 |
|
|
|
|
|
#endif
|
|
|