Hi,
This is what I am trying to do.
I am developing code for Quadcopter flight controller. The code takes data from receiver, Gyro and Accelerometer and calculates PID. For collecting data from receiver, I am using iBusBM library (IBusBM - Arduino Reference).
What I need?
It seems I can collect data each time the loop is repeated. I need the receiver data updated to variables whenever there is new data, not wait for the loop to complete. To me it sounds like hardware interrupt, but I don't know how I can implement interrupt with this library.
Following is simple Sketch for collecting 10 channel receiver data. How can I modify this Sketch so that whenever there is a new data, variables are updated and doesn't wait for rest of the Sketch to complete. (there is no rest of the Sketch in the sample code, but will be in actual Quadcopter flight controller once I build it). I am going through each stages.
#include <IBusBM.h>
IBusBM IBus; // IBus object
void setup() {
IBus.begin(Serial); // iBUS object connected to serial0 RX pin
Serial.begin(115200);
}
void loop() {
int val[9];
for (int i=0; i<10; i++){
val[i] = IBus.readChannel(i); // get latest value for 10 servo channel
Serial.print("Ch ");
Serial.print(i);
Serial.print(" = ");
Serial.print(val[i]);
Serial.print(" ; ");
}
Serial.println(" ");
delay(20);
}