Code Example

/*
  Testing RC Connection
  3/4/16
  Captures the Pulse signal from a RC controller
  Feel free to do whatever you want with this code example
*/

// Create Variables to hold the Receiver signals
int Ch1, Ch2, Ch3, Ch4, Ch5, Ch6;


void setup() {
  // Set the pins that the transmitter will be connected to all to input
  pinMode(12, INPUT); //I connected this to Chan1 of the Receiver
  pinMode(11, INPUT); //I connected this to Chan2 of the Receiver
  pinMode(10, INPUT); //I connected this to Chan3 of the Receiver
  pinMode(9, INPUT); //I connected this to Chan4 of the Receiver
  pinMode(8, INPUT); //I connected this to Chan5 of the Receiver
  pinMode(7, INPUT); //I connected this to Chan6 of the Receiver
  // Attach Speed controller that acts like a servo to the board

  Serial.begin(9600);
}

void PrintRC()
{ // print out the values you read in:
  Serial.println(" RC Control Mode ");
  Serial.print("Value Ch1 = ");
  Serial.println(Ch1);
  printBar(Ch1);
  Serial.print("Value Ch2 = ");
  Serial.println(Ch2);
  printBar(Ch2);
  Serial.print("Value Ch3 = ");
  Serial.println(Ch3);
  printBar(Ch3);
  Serial.print("Value Ch4 = ");
  Serial.println(Ch4);
  printBar(Ch4);
  Serial.print("Value Ch5 = ");
  Serial.println(Ch5);
  printBar(Ch5);
  Serial.print("Value Ch6 = ");
  Serial.println(Ch6);
  printBar(Ch6);
  Serial.println(" ");
  delay(50);
}

void printBar(int range) {
  for (int i = 0; i <= (range - 1000) / 10; i++) {
    Serial.print(" ");
  }
  Serial.println("*");
}

void loop()
{
  Ch1 = pulseIn(12, HIGH, 21000);
  Ch2 = pulseIn(11, HIGH, 21000);
  Ch3 = pulseIn(10, HIGH, 21000);
  Ch4 = pulseIn(9, HIGH, 21000);
  Ch5 = pulseIn(8, HIGH, 21000);
  Ch6 = pulseIn(7, HIGH, 21000);

  PrintRC(); //Print Values for RC Mode Diagnostics

}