Skip to content

Instantly share code, notes, and snippets.

@j0uni
Last active August 15, 2016 19:19
Show Gist options
  • Save j0uni/ab6371596c7f52838852a8a3ca195033 to your computer and use it in GitHub Desktop.
Save j0uni/ab6371596c7f52838852a8a3ca195033 to your computer and use it in GitHub Desktop.
Futaba SBUS latency test with Arduino Mega
void setup()
{
Serial.begin(115200);
Serial3.begin(100000);
pinMode(13, OUTPUT);
}
uint8_t buffer[255];
uint8_t bufferPos=0;
void loop()
{
while (Serial3.available())
{
uint8_t c=Serial3.read();
// a terrible hack, but works!
// it just monitors if the first channel is different than "normally"
if (c==0x0f)
{
digitalWrite(13, (buffer[1]!=96));
bufferPos=0;
}
buffer[bufferPos] = c;
bufferPos++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment