Not getting numbers from RC Receiver

I'm pretty new to programming Arduino, so I'm not sure what I'm doing wrong. I have an RC receiver hooked up to an Arduino Mega 2560 and when I read the values from the channels, all I'm getting is gibberish. There aren't any number values being returned. I know certain pins on the board do certain things, so I tried finding which pins to connect the receiver too but everything is giving me gibberish. Any help would be greatly appreciated.

#define CH1 4 // Right Stick Right/Left
#define CH2 5 // Right Stick Up/Down
#define CH3 6 // Left Stick Up/Down
#define CH4 7 // Left Stick Right/Left
#define CH5 8 // Switch A
#define CH6 9 // Switch B
#define CH7 10 // Switch E (3 way)
#define CH8 11 // Not used currently 
#define CH9 12 // Not used currently
#define CH10 13 // Not used currently

int ch1Value; // Right Stick Right/Left
int ch2Value; // Right Stick Up/Down
int ch3Value; // Left Stick Up/Down
int ch4Value; // Left Stick Right/Left
bool ch5Value; // Switch A
bool ch6Value; // Switch B
int ch7Value; // Switch E (3 way)
//int ch8Value;
//bool ch9Value;
//bool ch10Value;

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

  // Remote Reciever Setup
  pinMode(CH1, INPUT);
  pinMode(CH2, INPUT);
  pinMode(CH3, INPUT);
  pinMode(CH4, INPUT);
  pinMode(CH5, INPUT);
  pinMode(CH6, INPUT);
  pinMode(CH7, INPUT);
  pinMode(CH8, INPUT);
  pinMode(CH9, INPUT);
  pinMode(CH10, INPUT);

}

void loop() {
  // Get values for each channel
  ch1Value = readChannel(CH1, -100, 100, 0);
  ch2Value = readChannel(CH2, -100, 100, 0);
  ch3Value = readChannel(CH3, -100, 100, 0);
  ch4Value = readChannel(CH4, -100, 100, 0);
  ch5Value = readSwitch(CH5, false);
  ch6Value = readSwitch(CH6, false);
  ch7Value = readChannel(CH7, -100, 100, 0);

/*
  Serial.print("CH1: " + ch1Value);
  Serial.print(", CH2: " + ch2Value);
  Serial.print(", CH3: " + ch3Value);
  Serial.print(", CH4: " + ch4Value);
  Serial.print(", CH5: " + ch5Value);
  Serial.print(", CH6: " + ch6Value);
  Serial.println(", CH7: " + ch7Value);
  */

  Serial.println("CH1: " + pulseIn(CH1, HIGH, 30000));

  delay(1000);

}

int readChannel(int channelInput, int minLimit, int maxLimit, int defaultValue)
{
  int ch = pulseIn(channelInput, HIGH, 30000);
  if (ch < minLimit) return defaultValue;
  return map(ch, 1000, 2000, minLimit, maxLimit);
} //int readChannel()
 
// Read the switch channel and return a boolean value
bool readSwitch(byte channelInput, bool defaultValue)
{
  int intDefaultValue = (defaultValue)? 100: 0;
  int ch = readChannel(channelInput, 0, 100, intDefaultValue);
  return (ch > 50);
} // bool readSwitch()

So do you have a link to where you got the code you are running, or where you saw the code that you modified?

What receiver make and model are you using? Do you know that it is functioning correctly?

What means

There aren't any number values being returned

Is it printing numbers that make no sense, or literal ply not printing numbers at all, but gibberish? Is your serial monitor set up to match the begin(9600) call?

a7

I'm getting it from drone bot workshop, but I don't have the same setup he does. I have a Radiolink AT10II 12 Channels RC Transmitter and Receiver R12DS. I haven't touched this project in a long time and at one point it was working, but had made a lot of changes to the pins and I think that's where I messed up.

Here is an image of the gibberish it's putting out:

What do you think this does?

Serial.println("CH1: " + pulseIn(CH1, HIGH, 30000));

I'll bet you have better luck with something like this:

Serial.print("CH1: ");
Serial.println(pulseIn(CH1, HIGH, 30000));

yea that did it. Thanks :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.