Search code examples
arduinopwm

Read PWM Signal from Pixhawk to Arduino


I tried to read a PWM signal from Pixhawk by connecting it to Arduino. The Pixhawk is connected to FrSky X8R. But my PWM always reads to zero.

Here's my arduino code

#define RCPin 4
int RCValue;


void setup() {
  Serial.begin(9600);
  pinMode(RCPin, INPUT);
}

void loop() {
  RCValue = pulseIn(RCPin, HIGH,25000);
  Serial.println(RCValue);
}

The picture attached is also my wiring.

enter image description here


Solution

  • First of all pin 4 isn't a PWM pin. As i can see you're using Arduino UNO. In UNO PWM pins are: 3, 5, 6, 9, 10, 11 And their Frequencies: 490 Hz except pin 5 and pin 6, their frequencies is: 980 Hz.

    So, change your pin as 5 and it will work then.