Pulse In Only Receiving One Pin At A Time

Okay to put this simple I have recently purchased a wireless drone controller. I am able to connect it to my Arduino UNO and have it read the incoming signal with a pulse in command.

So basically I have pin 5 receiving a signal from the drone remote on whether or not to turn on the led connected to pin 8.

I was then looking to have pin 6 receive a separate button from the drone controller and output on the serial monitor whether or not it was on or off.

But for some strange reason, it won't work. I can't seem to have both pins getting a pulse in at the same time. It only reads whichever pin is listed first in the code.

int UpDown, LeftRight, OnOff, AutoMode;
int ledpin = 8;

void setup() {
  // put your setup code here, to run once:
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(ledpin, OUTPUT);// initialize the pin as an output

void loop() {
  // put your main code here, to run repeatedly:
  OnOff = pulseIn(5, HIGH, 21000);
  AutoMode = pulseIn(6, HIGH, 21000);

 if (AutoMode > 1000){

if (OnOff > 1000)
   digitalWrite(ledpin, LOW);//turn LED on
  digitalWrite(ledpin, HIGH);//turn LED off


Any help is greatly appreciated. I am pretty confused as to what I am doing wrong.

‘pulseIn’ is a blocking function to my knowledge. It also waits for a transition from LOW to HIGH in your code before it starts counting the duration.

So you call pulseIn for pin 5; it will wait for the transition. If no transition happens, it will timeout after a while. If a transition happens, it will wait for a transition from HIGH to LOW.

During this time, the transition from LOW to HIGH on pin 6 will not be detected.

Below ‘image’ shows what happens when the second pulse comes in while the first one is being processed

5       |         |
    ----+         +-------------------------------
        ^         ^                              ^
        5         6                             21
    |< pulseIn 5 >|
6            |         |
    ---------+         +-------------------------------
             ^         ^                              ^
           5.5       6.5                             21 + 6
                  |< pulseIn 6                       >|

With a pulse duration of 1 ms on pin 5, the pulse on pin 6 needs to come in after the pulse on pin 5 is completed.

If the duration of the pulses is not relevant, you can do a simple statechange detection on both pins. Else you have to search the web for a non-blocking pulseIn or write your own pulseIn function.