Hello! I have a problem with IbusBm and Ibus telemetry. If I run the codes separately, both work perfectly. When I merge them, the servo vibrates. I will attach the code; any help is welcome. I have a Flysky radio, an ia6b receiver, and an Arduino Mega 2560.
type or paste code here
``#include <IBusBM.h>
IBusBM IBUS;
#include <Servo.h>
Servo ESC;
#include <iBUSTelemetry.h>
iBUSTelemetry telemetry(11);
#include <TinyGPS++.h>
TinyGPSPlus gps;
int OutPin_2 = 25;
void setup() {
Serial.begin(9600);
ESC.attach(30);
pinMode(OutPin_2, OUTPUT);
telemetry.begin();
telemetry.addSensor(IBUS_MEAS_TYPE_SPE);
telemetry.addSensor(IBUS_MEAS_TYPE_GPS_STATUS);
IBUS.begin(Serial1, IBUSBM_NOTIMER);
if (Serial1.available()) { // Only show debug message if usb is connected
for (int i = 0; i < 10; i++) { // Show first 10 ibus channels
//Serial1.print(IBUS.readChannel(i));
// Serial1.print(" ");
}
}
}
void speed() {
ESC.writeMicroseconds(IBUS.readChannel(1));
}
void updateValues() {
// lecture donnes Gps et allumage LED si OK
while (Serial.available()) {
gps.encode(Serial.read());
}
telemetry.setSensorValue(1, gps.speed.kmph() * 10);
}
void led() {
if (IBUS.readChannel(4) > 1900) {
digitalWrite(OutPin_2, HIGH);
}
if (IBUS.readChannel(4) < 1100) {
digitalWrite(OutPin_2, LOW);
}
}
void loop() {
telemetry.run();
speed();
IBUS.loop();
led();
}`