需要帮助编写代码以在 Arduino 中使用 PID 控制无人机电机

问题描述 投票:0回答:0

我正在尝试使用PID来控制无人机的左右电机,使其稳定在0度角。电位器校准是,角度为 0 时 Vpot 为 522,角度为 -22 时为 729,角度为 22 时为 371。有人可以使用此信息写我的 PID 吗?我坚持下去了。

我已经包含了我写的代码的第一部分:

void loop() {
  potValue = analogRead(potPin);
  angle = map(potValue, 0, 1023, -22, 22);
  // Map potValue range to -22 to 22 degrees
c++ arduino-uno pid
© www.soinside.com 2019 - 2024. All rights reserved.