hi,
i'm trying to read only one channel on my RC receiver (Spektrum AR6100).
then move a servo with the servo.h librarie
my problem, is the same a several people: servo jitter....
when use a fixed false input, the servo does not jitter.
so i was playing with a simple sketch to read only the input value.
the result is clear, i don't have a fixed value, it's oscilating, a little, but enough to make jittet to the servo.
i'm sure there is a better way to read the input
my code:
void loop() {
rxRposi = 0;
for (int i = 0; i < rxRsamples; ++i) {
rxRpos = pulseIn(pinRchannel, HIGH);
rxRposi = rxRpos + rxRposi;
if (rxRpos < rxRmini){
rxRmini= rxRpos;
}
if (rxRpos > rxRmaxi){
rxRmaxi = rxRpos;
}
//delay (2);
}
rxRpostotal = rxRposi;
rxRposave = abs(rxRposi / (rxRsamples));
//if (rxRposave == 0 || rxRposave < 1000 || rxRposave > 2000) {
// return;
//}
//svRpos = map(rxRposave, 1000, 2000, 0, 180);
//svRpos = constrain (svRpos, 0, 180);
//rudder.write(svRpos);
Serial.println("rxRpostotal....rxRposave....rxRsamples....rxRmini...rxRmaxi" );
Serial.print("....");
Serial.print(rxRpostotal);
Serial.print(".........");
Serial.print(rxRposave);
Serial.print(".........");
Serial.print(rxRsamples);
Serial.print(".........");
Serial.print(rxRmini);
Serial.print(".........");
Serial.println(rxRmaxi);
}
thanks for your help