And for two channels (with RC output pulses of 1000 to 3000 uS instead of 1000 to 2000):
const int inputPinA = 2; // The pin connected to the RC receiver's servo output A
const int outputPinA = 3; // Output PWM pin A
const int inputPinB = 4; // The pin connected to the RC receiver's servo output B
const int outputPinB = 5; // Output PWM pin B
void setup() {
pinMode(inputPinA, INPUT);
pinMode(inputPinB, INPUT);
}
void loop() {
unsigned long pulseLength;
pulseLength = constrain(pulseIn(inputPinA, HIGH), 1000, 3000);
analogWrite(outputPinA, map(pulseLength, 1000, 3000, 0, 255));
pulseLength = constrain(pulseIn(inputPinB, HIGH), 1000, 3000);
analogWrite(outputPinB, map(pulseLength, 1000, 3000, 0, 255));
}