Enter Your Project for a chance to win a Nano Grand Prize bundle for the most innovative use of Arduino plus a $400 shopping cart! Back to homepage | Project14 Home | |
Monthly Themes | ||
Monthly Theme Poll |
This blog post will show you how you can use a FLYSKY RC controller with an Arduino. As part of this demo project I am using the RC controller to control a couple of servos, this concept can be used to control animatronic projects which need DC motors and servos or any other kind of lighting setup. Basically, this project is just a demo and could have achieved by connecting the servo's directly to the receiver, but my plan as part of a couple of future projects is to drive DC motors/steppers and servos to build battle bots..
Circuit
The RC controller receiver FLYSKY AFHDS 6 channel is connected to the Arduino Nano PWM pins, the receiver pins are meant to connect servos
- Any middle pin on the receiver is connected to 5V pin on the Arduino Nano
- and the outermost pin is connected to the GND pin
- CH1 is connected to PWM pin#6 on the Nano, which corresponds to roll on the plane
- CH2 is connected to PWM pin#10 on the Nano, which corresponds to pitch on the plane
And the servos are connect to
- Servo for the base of the 3D printed arm is connected to PWM pin#3
- And the Arm is connected to PWM pin#5
Arduino Code
Here is the Arduino Code used to print the RC controller inputs to Serial monitor of the Arduino IDE, and control the two servos
//Created for Project14 using Arduino Nano , Flysky RC(AFHDS) controller and Servos. #include <Servo.h> int ch1=6; //roll on the RC controller int ch3=10;//pitch on the RC controller const int servoBasePin = 3; //Servo connected to the top base of the 3D printed part const int servoTeaArmPin = 5; //Servo connected to the Tea bag holder arm of the 3D printed part Servo servoBase; Servo servoTeaArm; int servoValRoll, servoValPitch; void setup() { Serial.begin(9600); pinMode(ch1, INPUT); pinMode(ch3, INPUT); servoBase.attach(servoBasePin); servoTeaArm.attach(servoTeaArmPin); } void loop() { int ch3Pitch = pulseIn(ch3,HIGH,25000); int ch1Roll = pulseIn(ch1,HIGH,25000); Serial.print("ch3_pitch : "); Serial.println(ch3Pitch); Serial.print("ch1_roll: "); Serial.println(ch1Roll); //Mapping the postions to the servos servoValPitch = map(ch3Pitch, 1000, 2000, 0, 180);//values from pitch from 900 to 2000 servoBase.write(servoValPitch); servoValRoll = map(ch1Roll, 1000, 2000, 0, 180);//values for roll from 1000 to 2000 servoTeaArm.write(servoValRoll); delay(50);// increase/decrease the delay to match the movement on the gimbal of the RC controller. }
3D printed parts
For the 3D printed parts i used the STL files from the Automated Tea Dunker , to print all the 3D printed parts I used Hatchbox 1.75mm PLA and a Flashforge creator pro.
Here is a quick video demo of the Automated Tea Dunker in action with the RC controller
Top Comments