STM32编码器控制舵机
运用TIM2和TIM3得到编码器输入和输出PWM波控制sg90舵机旋转角度
main.c
#include "stm32f10x.h" // Device header
#include "OLED.h"
#include "Encoder.h"
#include "Servo.h"
int16_t angle;
int main(void)
{
OLED_Init();
Encoder_Init();
Servo_Init();
while (1)
{
OLED_ShowSignedNum(1, 1, Encoder_Get(), 5);
angle = Encoder_Get();
if(angle < -100)
angle = -100;
else if(angle > 100)
angle = 100

最低0.47元/天 解锁文章
4268

被折叠的 条评论
为什么被折叠?



