Stm32Project/Src/servo.c

17 lines
302 B
C
Raw Normal View History

2024-11-06 22:26:06 +08:00
#include "servo.h"
#include "tim.h"
uint8_t Servo_Speed=1,Servo_goal=0,Servo_position=0;
void Servo_SetAngle(int goal)
{
Servo_position=goal;
__HAL_TIM_SET_COMPARE(&htim15,TIM_CHANNEL_2,2500*goal/180-500);
}
//往哪个方向转
int Servo_toward(void)
{
return Servo_goal>Servo_position;
}