我正在尝试使用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