OVERVIEW
We all have that old Radio Controlled helicopter, plane, drone…
That we bought, played with it once or twice, crashed once, twice, three times, and now it’s just there collecting dust.
Well why not use the transmitter and receiver to control an Arduino project at great distances.
The range on even the simplest of RC transmitter is around 300-500 feet, which is much better than any Bluetooth or WiFi connection.
Of course compared to those it’s not as versatile and it’s only a one way communication, but for turning on relays or lighting some Led’s it can be very useful.
In this tutorial we will see how to extract the values from the RC Receiver (the one that’s in the heli, plane, etc…), and display them in PUTTY, which is more versatile than using the Serial Monitor that’s included with the Arduino IDE software.
PARTS USED
Arduino UNO
These are Amazon affiliate links...
They don't cost you anything and it helps me keep the lights on
if you buy something on Amazon. Thank you!
CONNECTIONS
We will be connecting 2 channels from the RC Receiver, but you can connect as many as are available on the Receiver you are using.
Channel 1 is connected to pin 8
Channel 2 is connected to pin 9
We are using the 5V and Ground from the UNO to power the RC Receiver directly.
Note: Most recent RC Receiver follow this guideline for the pins:
Left to Right: ‘Signal Pin’ – ‘Positive’ – ‘Negative (Ground)’
or wire color: ‘Yellow’ – ‘Red’ – ‘Black’
THE CODE
We are using the ‘PulseIn’ function to count the amount of micro seconds between pulse from the RC Receiver.
‘PulseIn’ will wait for the pin to go ‘HIGH’ in our example, start a timer, then waits for the pin to go ‘LOW’.
The timer result will then be saved in a variable that we will display in PUTTY.
Of course you can also use the Arduino IDE Serial Monitor to display the results, but since the results will be scrolling very fast it might be hard to read, which is why PUTTY is better since we can include some ‘Clear Screen’ and ‘Home’ commands inside our code.
You can find a link to download ‘PUTTY’ at the bottom of this page.
As always you can have a look at the tutorial video for more information.
#define rcPin1 8 // Pin 8 Connected to CH1 of Transmitter;
#define rcPin2 9 // Pin 9 Connected to CH2
int ch1 = 0; // Receiver Channel 1 PPM value
int ch2 = 0; // Receiver Channel 2 PPM value
void setup() {
pinMode(rcPin1, INPUT);
pinMode(rcPin2, INPUT);
Serial.begin(9600);
}
void loop() {
// Read in the length of the signal in microseconds
ch1 = pulseIn(rcPin1, HIGH, 20000); // (Pin, State, Timeout)
ch2 = pulseIn(rcPin2, HIGH, 20000);
Serial.print("Channel #1: ");
Serial.println(ch1);
Serial.print("Channel #2: ");
Serial.println(ch2);
Serial.println("------------");
delay(500);
// Clear screen and move cursor Home, only works in PUTTY
Serial.write(27); // ESC command
Serial.print("[2J"); // clear screen command
Serial.write(27);
Serial.print("[H"); // cursor to home command
}
TUTORIAL VIDEO
DOWNLOAD
Copy the above Sketch code in your Arduino IDE software to program your Arduino.
You can download PUTTY here if you wish to use it instead of the Arduino IDE Serial Monitor.
Comments