1. 让小车动起来
智能小车1-智能小车的初认识_void motor-CSDN博客
接线
B-1A -- PB0B-1B -- PB1A-1A -- PB2A-1B -- PB10
CubeMx
1.常规配置
SYS->Debug->Serial Wire
RCC->High Speed Clock(HSE)->Crystal/Ceramic Resonator
时钟树HSE、PLLCLK打开,HCLK设置成72MHz
打开GPIO口
可以在这修改(重定义)GPIO口名称,相应的在main.h文件中修改
2.生成代码
keil
main.c
int main(void)
{
while (1)
{
Motor_front();
HAL_Delay(1000);
Motor_back();
HAL_Delay(1000);
Motor_Left();
HAL_Delay(1000);
Motor_Right();
HAL_Delay(1000);
Motor_Stop();
HAL_Delay(1000);
}
}
main.h
#define B_1A_Pin GPIO_PIN_0
#define B_1A_GPIO_Port GPIOB
#define B_1B_Pin GPIO_PIN_1
#define B_1B_GPIO_Port GPIOB
#define A_1A_Pin GPIO_PIN_2
#define A_1A_GPIO_Port GPIOB
#define A_1B_Pin GPIO_PIN