I have been trying on the following code for reading SBUS input from a frsky receiver:
#include "Wire.h"
#include "SBUS.h"
// a SBUS object, which is on hardware
// serial port 1
SBUS x8r(Serial1);
// channel, fail safe, and lost frames data
uint16_t channels[16];
bool failSafe;
bool lostFrame;
void setup() {
Wire.begin();
Serial.begin(115200);
// begin the SBUS communication
x8r.begin();
}
void loop() {
int i = 1;
// look for a good SBUS packet from the receiver
Serial.println("h");
if(x8r.read(&channels[0], &failSafe, &lostFrame)){
Serial.println("h234 ");
// write the SBUS packet to an SBUS compatible servo
for (i=0; i < 8; i++) {
Serial.print(i);
Serial.print(" :");
Serial.print(channels);
Serial.print(" "); };
Serial.println();
x8r.write(&channels[0]);
}
}
I am using Pin0 (RX1) (and also tried RX5) on Teensy4 as input and the SBUS signal from the receiver passes through an inverter circuit. This code and setup works on an Arduino Mega 2560 board, but not on the teensy4. Please help.
#include "Wire.h"
#include "SBUS.h"
// a SBUS object, which is on hardware
// serial port 1
SBUS x8r(Serial1);
// channel, fail safe, and lost frames data
uint16_t channels[16];
bool failSafe;
bool lostFrame;
void setup() {
Wire.begin();
Serial.begin(115200);
// begin the SBUS communication
x8r.begin();
}
void loop() {
int i = 1;
// look for a good SBUS packet from the receiver
Serial.println("h");
if(x8r.read(&channels[0], &failSafe, &lostFrame)){
Serial.println("h234 ");
// write the SBUS packet to an SBUS compatible servo
for (i=0; i < 8; i++) {
Serial.print(i);
Serial.print(" :");
Serial.print(channels);
Serial.print(" "); };
Serial.println();
x8r.write(&channels[0]);
}
}
I am using Pin0 (RX1) (and also tried RX5) on Teensy4 as input and the SBUS signal from the receiver passes through an inverter circuit. This code and setup works on an Arduino Mega 2560 board, but not on the teensy4. Please help.