Transmitter-Reciever Arduino Connection

In continuing my plan on using the Arbotix to be the base of the aerial platform, I was ready to test the translation of pulse signals from the transmitter through arduino to the servo, and ultimately the ESCs for motors.  The transmitter I am using is the FlySky CT6B, which comes with a 6 channel receiver ($35 US).  I programmed the Arbotix (Arduino) with a sketch that uses the Servo library.  Basically, it takes the pulse signals from the receiver and using library, outputs to servo the intended angle (which is translated into PPM or PWM, depending on which blog you follow, I just like to say ‘pulses’).

#include <Servo.h>
int ch3in; // Throttle
int ch4in;  //Rudder, yaw
int ch3out;
float ch4out;
int ch3min;
int ch3max;
int ch4min;
int ch4max;
float ch4smth; //this is the smoothed variable
int ch4hold;  // in case it is needed to refer to later
Servo outS4;  //variable for ch4 out to servo
void setup() {
  pinMode(3, INPUT); // digital input throttle
  pinMode(4, INPUT);  //digital input rudder
  pinMode(17, OUTPUT); // not sure if this works as analog 7
  pinMode(7, OUTPUT);  // for sure works with servo library
  outS4.attach(7);
  ch4min = 1500;
  ch4max = 1500;
  ch3out = 0;
  ch4out = 90;
  ch4smth = ch4out;
  Serial.begin(19200); // little faster than 9600
}
void loop() {
  ch3in = pulseIn(3, HIGH, 25000); // Read pulse
  ch4in = pulseIn(4, HIGH, 25000); // ditto
  //calcs for out
  if (ch4in < ch4min && ch4in > 900)
   {
     ch4min = ch4in;
   }�
  if (ch4in > ch4max)
   {
     ch4max = ch4in;
   }
  ch4out = map((ch4in/10),(ch4min/10),(ch4max/10),83,109);
  ch4out = constrain(ch4out,83,109);
  //smooth here
  ch4smth = (ch4smth + ch4out)/2;
  ch4hold = ch4smth;
  outS4.write(ch4smth);
  delay(6);
�
  Serial.print("  Channel 4 out:");
  Serial.println(ch4smth);
�
}

That is the test sketch.  There is a little bit of smoothing in there and  it does seem less jerky than using basic servo library example.  The response is pretty good and I just have to calibrate the angles and the physical location of the servo horn, and that should be good for the Yaw/rudder.  Much more complicated will be the integration of IMU(s) and control of the ESCs and motors.  Here is the filtering test below.