hey all has anyone used pulseIn() to read signals from a RC rx like spektrums since they dont use ppm signals im trying to just read the pulses. im having trouble getting a clean signal it seems to want to just jump around. this wasnt a problem for me till now that im trying to be a little more accurate with the data and the jumping even if i apply digitalsmooth() to the data still wont get me where i need to be. any suggestions here is my code.
#define TIMEOUT 100
// { roll, pitch, yaw }
float angles[3] = {0.0, 0.0, 0.0};
#include <Servo.h>
Servo motor1;
int pos = 0;
int pin3 = 3;
int pin4 = 4;
int pin5 = 5;
int pin6 = 6;
int pin7 = 7;
int pin8 = 8;
int pin9 = 9;
int pin10 = 10;
int pin11 = 11;
int threshold = 30; //threshold for smoothing Rx data
int uGear = 0, uYaw = 0, uPitch = 0, uRoll = 0, uThrtl = 0,uGear1 = 0, uYaw1 = 0, uPitch1 = 0, uRoll1 = 0, uThrtl1 = 0;
void setup() {
Serial.begin(57600);
Serial1.begin(57600);
motor1.attach(8);
pinMode(pin3, INPUT);
pinMode(pin4, INPUT);
pinMode(pin5, INPUT);
pinMode(pin6, INPUT);
pinMode(pin7, INPUT);
}
void loop() {
uThrtl = pulseIn(pin3, HIGH);
uRoll = pulseIn(pin4, HIGH);
uPitch = pulseIn(pin5, HIGH);
uYaw1 = pulseIn(pin6, HIGH);
uGear = pulseIn(pin7, HIGH);
Serial.print("Throttle: ");
Serial.print(uThrtl); //throttle
Serial.print("Yaw: ");
Serial.print(uYaw);
Serial.print("Pitch: ");
Serial.print(uPitch);
Serial.print("Roll: ");
Serial.print(uRoll);
Serial.print("Gear: ");
Serial.print(uGear);
Serial.println("");
}