RC switch toggle problem

Hi everyone,

I am using a Futaba receiver and transmitter. My objective is very simple - When I toggle a switch in the RC transmitter the LED(connected to PIN 13) should light up and when I toggle to the other position it should switch off.

I power up the receiver from the 5V of the Arduino UNO and the grounds of both RC receiver and Arduino UNO are connected together. My problem is, when the switch is at low position the light is off and when the switch is at high position the light is BLINKING RANDOMLY!!!! :astonished: THE BLINKING NEVER STOPS as long as the switch is in High Position.

I tried using the proportional switches there is no problem. Only when I use a simple toggle switch with ON and OFF position this problem occurs...

Basically when the switch is at Low position it produces a High pulse for 950us for every 14 ms and when the switch is at High position it produces a High pulse for 2050us for ever 14ms = PWM signal and hence my reasoning to choose 1050us in the codes so to choose a middle value between 950us and 2050us.

/* Codes for the RC switch to on and off LED */

int autopilot = 3;
int thr_output = 13;
unsigned long duration;

void setup(){
  pinMode(autopilot, INPUT);
  pinMode(thr_output, OUTPUT);
}

void loop(){
  duration = pulseIn(autopilot, HIGH);
  if (duration < 1050)
  {
    digitalWrite(thr_output, LOW);   
  }
  
  else
  {
    digitalWrite(thr_output, HIGH);
  }
  
 
}

Please enlighten me why is this problem and what can I do to solve this?? =( :~

Try writing a sketch that measures a pulse, outputs the value to Serial Monitor, and waits for a bit (delay(1000);). Then you can see exactly what values you are getting. Perhaps the switch is faulty. Perhaps your threshold is not in the middle of the actual values you are getting.

Hi,

Thanks for the reply.

As you said I used serial output. But I couldn't make out much of it; hence, I used a oscilloscope and found that the signal was very noisy, so I used few capacitors of small value (0.01uF) to filter the noise.

The problem is resolved!