Go Down

Topic: Pulsein function, getting inaccurate data (Read 255 times) previous topic - next topic

paramesium

hi guys,

I used the below code (part of the program) and try to obtain rc signal from my RC receiver.

Code: [Select]
 
if(sensor_update == true && ((timeNow-timer)>=20))
  {
      ch1 = pulseIn(5,HIGH,20000);
      Serial.println(ch1);
      sensor_update = false;
     
  }


the joy stick of the transmitter is static but I got my output as follow

Code: [Select]

1132
1132
1
1132
1132
1
1126
1132
614
1132
1
1
1126
1132
1
1132
1
1132
131
1
1132
965
1132
1132
1132
1132
831
1132
1
5
1132
1126
1
1


Can anyone explain to me why is this happening, and how can I solve this?
thanks a lot!

Jack

UKHeliBob

How is the joystick connected to the Arduino ?
Seeing your whole code would also be helpful
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Go Up