Introduction: How to Control Arduino With RC Receiver in 10 Minutes

In this tutorial I will be showing you how to control your Arduino with a RC receiver and transmitter. This is a very easy set up and only take about 10 minutes depending on how many things you are controlling. In this tutorial when the rudder stick is set left or right it will make the servo sweep (100 degrees to 0 degrees and back) but you could make it do more then just that.

Step 1: Resources

Items:

Arduino Uno or Mega

R/C controller and receiver (I'm using an expensive controller because I fly petrol aircraft)

(only needs to be cheapo)

servo (for example)

Step 2: Wiring

Ok you need to plug a wire from pin 7 to ch3 (and then if you want to add more channels you just need to plug in more pins) on the receiver at the top for the information line. Then plug positive which is the middle one to 5v on Arduino and then GND to GND.

The servo for this example is connected to pin 9 so hook it in and then GND to GND and vcc to 3.3v just for now or you can plug it into a separate battery pack.

Thats all the wiring for this tutorial

Step 3: Code

You code change this code to control motors or make it that the servos are more precise on where they move, but this is just for an example so you guys can get started, if you change or use this code please mention me in that i wrote out most of the code except that Nick Poole wrote out the pulse in part.

// RC PulseIn Serial Read out By: Nick Poole

//extended By Jason Mclaughlin

//2015

#include <Servo.h> // for servo in example

Servo myservo; //servo entity

int pos = 0; //position for servo

int ch1; // Here's where we'll keep our channel values

int ch2;

int ch3;

void setup() { myservo.attach(9);

pinMode(5, INPUT); // Set our input pins as such

pinMode(6, INPUT); pinMode(7, INPUT);

Serial.begin(9600); // Pour a bowl of Serial

}

void loop() {

ch1 = pulseIn(5, HIGH, 25000); // Read the pulse width of

ch2 = pulseIn(6, HIGH, 25000); // each channel

ch3 = pulseIn(7, HIGH, 25000);

Serial.print("Channel 1:"); // Print the value of

Serial.println(ch1); // each channel

Serial.print("Channel 2:");

Serial.println(ch2);

Serial.print("Channel 3:");

Serial.println(ch3);

if ((ch3 >= 1500) && (ch3 <= 1600)){// the center postion for controller

Serial.println("between");

pos = 90;//set servo to center

myservo.write(pos); // set to pos which is 90

}

else{

Serial.println("not between");

for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees

{ // in steps of 1 degree

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(1); // waits 1ms for the servo to reach the position

}

for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees

{

myservo.write(pos); // tell servo to go to position in variable 'pos'

delay(1); // waits 1ms for the servo to reach the position

}

}

delay(100); // I put this here just to make the terminal

// window happier

}

Step 4: Test

You made need to change this part of your code:

if ((ch3 >= 1500) && (ch3 <= 1600)){// the centre position for controller

Because the centre of your controller may have a different pulse output, to change it open serial monitor window and centre your stick it will have a number and that is your centre it may change, mine change randomly buy 100 so that is why it is between 1500 and 1600 because those are my centre numbers.

Have fun, I hope you liked this tutorial, because I was stuck with this and wanted to control my Arduino as well and I have figured it out and shared for everyone.

:)

Comments

About This Instructable

1,296views

22favorites

License:

Bio: I love the song Come Get Your Love
More by JaceDuino :How to control motors with Arduino and RC receiver in 10 minutesHow to control Arduino with RC receiver in 10 minutesEasy Arduino Light following Robot
Add instructable to: