I have read in multiple channels from an RC receiver using one pin for each channel.
I will post the code I have.
It should be possible to tie all the odd channels to one pin and all the even channels to another pin, and get any number of channels on just 2 pins. This assumes that the channels are produced sequentially (which I believe is accurate). I will have to try this at home some time, because I hate giving up all those inputs. Some diodes similar to this:
If you are reading an odd number of channels, I understand that you can go on a single pin, just calculating the even channel durations by the gap between the odd channel signals.
But on to my code for individual pins for each channel.
I have code in 3 tabs. The first:
void serviceServos(long pFrameCounter);
int Chan1Interrupt = 5; // pin 18
int Chan2Interrupt = 4; // pin 19
int Chan3Interrupt = 3; // pin 20
int Chan4Interrupt = 2; // pin 21
int Chan5Interrupt = 1; // pin 3
int Chan6Interrupt = 0; // pin 2
unsigned long Chan1_startPulse, Chan2_startPulse, Chan3_startPulse, Chan4_startPulse, Chan5_startPulse, Chan6_startPulse;
volatile double Chan1_val, Chan2_val, Chan3_val, Chan4_val, Chan5_val, Chan6_val;
volatile double Chan1_val_last, Chan2_val_last, Chan3_val_last, Chan4_val_last, Chan5_val_last, Chan6_val_last;
volatile long OutputThrottle;
////////////////////// For the Servo_in subroutine!!!!! ////////////////////
attachInterrupt(Chan1Interrupt, Chan1_begin, RISING);
attachInterrupt(Chan2Interrupt, Chan2_begin, RISING);
attachInterrupt(Chan3Interrupt, Chan3_begin, RISING);
attachInterrupt(Chan4Interrupt, Chan4_begin, RISING);
attachInterrupt(Chan5Interrupt, Chan5_begin, RISING);
attachInterrupt(Chan6Interrupt, Chan6_begin, RISING);
for (uint8_t i=1;i<=4;i++)
ServoArray[i].attach(22+i, 1000, 2000);
StartMillis = millis();
LocalMillis = millis();
LocalFrameCounter = (LocalMillis - StartMillis) / 20;
if (LocalFrameCounter > FrameCounter)
FrameCounter = LocalFrameCounter;
more on a later post since I exceeded the max