Serial Read PWM

Hi, I am using the following code to read PWM from one channel of an RC receiver and trigger the shutter of a camera.

#include <multiCameraIrControl.h>
const int buttonPin=9;
unsigned long buttonState;

Sony NEX5N(2);

void setup(){
pinMode(13,OUTPUT);
pinMode(buttonPin,INPUT);
Serial.begin(9600);
}

void loop(){
buttonState=pulseIn(buttonPin,HIGH);
Serial.println(buttonState);
if(buttonState>2095){
NEX5N.shutterNow();
delay(2000);
digitalWrite(13,LOW);
}
else if(buttonState>1549 && buttonState<1560){
NEX5N.shutterNow();
delay(800);
NEX5N.shutterNow();
delay(800);
NEX5N.shutterNow();
delay(800);
NEX5N.shutterNow();
delay(800);
}
else if(buttonState>997 && buttonState<1005){
NEX5N.toggleVideo();
delay(5000);
}
else{
digitalWrite(13,LOW);
}
}

But looking at the serial monitor, the numbers that appear look rather random rather than following the input from my transmitter, would there be something on the code?

I am directly connecting the signal from receiver to the 9 pin in arduino

Thanks

first, use code tags around your code.

Second, give this a try:

while( digitalRead(buttonPin)==HIGH );
buttonState=pulseIn(buttonPin,HIGH);

What may be happening is that you may be starting a pulseIn while the signal is already HIGH, so you're not getting the full pulse. The extra line I posted will block until the signal is LOW, and then run pulseIn, letting you get the full pulse time.

Thanks,

Sharing ground of receiver with board did the magic!

I think the interupt line causes some disruption when changing the PWM from the Tx