Input from R/C receiver

Hi,

I’m controlling my robot from an old R/C receiver from an helicopter.

Here’s my code for reading

[code]
//Code from eswink http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1290626864

for (int i = 0; i < 3; i++){ //for each of the 3 channels:
RXSG* = pulseIn(RXCH*, HIGH, 100000); //read the receiver signal

if (RXSG* < 1085)   //if the signal is not good then use previous, else use the new signal
    RXSG* = RXOK*; 
else
    RXOK* = RXSG*;   

PWMSG* = map(RXSG*, 1085, 1765, 0, 255);				//substitute the high values to a value between 0 and 255
PWMSG* = constrain (PWMSG*, 0, 255);[/code]

The problem is that it’s not clean. Sometimes it just drop for one iteration to 0, so I have to keep the last value and use that one in case of a 0-drop. But what if I get more than one 0 one after the other?

Any recommendation?

Seb***********

RobotShop staff don’t usually troubleshoot code, so perhaps someone from the community would be kind enough to take a look. Can you indicate which software you are using?