|
- 部分功能實現:
- ①小車前進后退左轉右轉
- #include "stm32f10x.h"
- #include "delay.h"
- #include "motor.h"
- /*
- void ZYSTM32_run(int speed,int time); //前進函數
- void ZYSTM32_brake(int time); //剎車函數
- void ZYSTM32_Left(int speed,int time); //左轉函數
- void ZYSTM32_Spin_Left(int speed,int time); //左旋轉函數
- void ZYSTM32_Right(int speed,int time); //右轉函數
- void ZYSTM32_Spin_Right(int speed,int time);//右旋轉函數
- void ZYSTM32_back(int speed,int time); //后退函數
- */
- int main(void)
- {
- delay_init();
- TIM4_PWM_Init(7199,0); //初始化PWM
- while(1)
- {
- ZYSTM32_back(50,1000);//后退1s
- ZYSTM32_brake(500);//停止0.5S
- ZYSTM32_run(50,1000);//前進1S
- ZYSTM32_brake(500);//停止0.5S
- ZYSTM32_Left(50,1000);//左轉1S
- ZYSTM32_Right(50,1000);//右轉1S
- ZYSTM32_Spin_Right(50,1000);//向右旋轉2S
- ZYSTM32_Spin_Left(50,1000);//向左旋轉2S
- ZYSTM32_brake(500);//停止0.5S
- }
- }
復制代碼
小車實物圖+板子原理圖
|
|