void OutputCh(byte ch, int pwm) { pwm=constrain(pwm,900,2100); pwm*=2; switch(ch) { case 0: OCR5B=pwm; break; //ch0 case 1: OCR5C=pwm; break; //ch1 case 2: OCR1B=pwm; break; //ch2 case 3: OCR1C=pwm; break; //ch3 case 4: OCR4C=pwm; break; //ch4 case 5: OCR4B=pwm; break; //ch5 case 6: OCR3C=pwm; break; //ch6 case 7: OCR3B=pwm; break; //ch7 case 8: OCR5A=pwm; break; //ch8, PL3 case 9: OCR1A=pwm; break; //ch9, PB5 case 10: OCR3A=pwm; break; //ch10, PE3 } } int InputCh(byte ch) { return (PWM_RAW[ch]+600)/2; } void Init_PWM1(void) { pinMode(11,OUTPUT); pinMode(12,OUTPUT); pinMode(13,OUTPUT); //Remember the registers not declared here remains zero by default... TCCR1A =((1<= 0x01) { if(Start_Pulse>Stop_Pulse) //Checking if the Stop Pulse overflow the register, if yes i normalize it. { Stop_Pulse+=40000; //Nomarlizing the stop pulse. } Pulse_Width=Stop_Pulse-Start_Pulse; //Calculating pulse if(Pulse_Width>5000) //Verify if this is the sync pulse { PPM_Counter=0; //If yes restart the counter } else { PWM_RAW[PPM_Counter]=Pulse_Width; //Saving pulse. PPM_Counter++; } Start_Pulse=ICR4; TCCR4B &=(~(1<