radio control with arduino

252 Views Asked by At

Hi I am attempting to read from an rc transmitter using an Arduino Uno board, I have a signal pin connected from the receiver to pin 9 on the Arduino. Here is the code I would really appreciate some help all I am trying to achieve is the read the pmw from the receiver. I am able to plug a servo into the receiver and that works fine along with a motor I am just struggling when I try and use the Arduino with the receiver. When I run my program all I get in the Serial monitor are values such as 9991,9972,10030,10050 that are completely unrelated.

I want to have a pmw value that I can map to 0-255 in order to control a motor

My Circuit: battery -> ESC(for BEC to regulate five volts back to receiver)-> receiver -> ch3 signal pin -> Arduino uno (pin9)

void setup() {
  Serial.begin(9600);
}

void loop() {
  int pwm = pulseIn(9, HIGH, 25000);
  Serial.println(pwm);
  delay (5);
}
1

There are 1 best solutions below

16
Rojo On

You are using pulseIn which returns a time (in ms). The time being how long it waited for a HIGH signal. If you want the actual value, use analogRead. You can still use pulseIn, just don't use the return value

void setup() {
  Serial.begin(9600);
}

void loop() {
  byte pwm = analogRead(A5) / 4;
  Serial.println(pwm);
  delay(5);
}