"The SoftwareSerial library has been developed to allow serial communication on other digital pins of the Arduino, using software to replicate the functionality (hence the name "SoftwareSerial"). It is possible to have multiple software serial ports with speeds up to 115200 bps. A parameter enables inverted signaling for devices which require that protocol. "

pin = PIND; // PIND indicates the state of each PIN for the arduino port dealing with [D0-D7] digital pins (8 bits variable)

mask = pin ^ PCintLast; // doing a ^ between the current interruption and the last one indicates wich pin changed sei(); // re enable other interrupts at this point, the rest of this interrupt is not so time critical and can be interr pted safely PCintLast = pin; // we memorize the current state of all PINs [D0-D7]

cTime = micros(); // micros() return a uint32_t, but it is not usefull to keep the whole bits => we keep only 16 bits

// mask is pins [D0-D7] that have changed // chan = pin sequence of the port. chan begins at D0 and ends at D7 if (mask & 1<<0) //indicates the bit 0 of the arduino port [D0-D7], that is to say digital pin 2, if 1 => this pin has just changed if (!(pin & 1<<0)) { //indicates if the bit 0 of the arduino port [D0-D7] is not at a high state (so that we match here only descending PPM pulse) dTime = cTime-edgeTime[0]; if (900<dTime && dTime<2200) rcPinValue[0] = dTime; // just a verification: the value must be in the range [1000;2000] + some margin } else edgeTime[0] = cTime; // if the bit 0 of the arduino port [D0-D7] is at a high state (ascending PPM pulse), we memorize the time