element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
NanoRama
  • Challenges & Projects
  • Project14
  • NanoRama
  • More
  • Cancel
NanoRama
Blog Arduino Nano bot - using RC controller
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join NanoRama to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: carmelito
  • Date Created: 14 May 2020 3:29 PM Date Created
  • Views 2649 views
  • Likes 6 likes
  • Comments 0 comments
  • arduino nano
  • flysky
  • 3D Printing
  • rc remote controller
  • nanoramach
Related
Recommended

Arduino Nano bot - using RC controller

carmelito
carmelito
14 May 2020

Here is another version of the Arduino Nano bot that is controlled using an RC controller, basically the pitch and roll on the RC controller is used to move, turn and control the speed of the bot. In the previous version of bot an ultrasonic sensor was used to control the movement of the bot, so that it does not crash into walls, and you can find the info at - Arduino Nano bot - using ultrasonic sensor .

 

image

Binding receiver to the transmitter

If you bought a transmitter and receiver as one pack the binding should have been taken care off . But if you bought them separately you will have to do the binding yourself, basically you will have to select the correct protocol of the receiver on you transmitter in the setting , in my case I am using a Flysky FS-I6 transmitter with a 6 channel AFHDS reciver.

To bind, add the bind plug and connect any pin on the outermost rail of the receiver to GND, green wire in the picture below, and any pin on the middle rail to 5V on the Arduino nano, this will cause the LED on the receiver to blink, then press the bind button on the transmitter and power it on. Once done, shutdown the transmitter and power off the Nano, remove the bind plug. Now when you turn on the transmitter and power on the Nano , you should see the receiver bound to the transmitter, and the LED on the receiver will be continuously on.

image

 

3D printed parts

Here is a picture of the 3D printed parts which are designed in Fusion 360. You can use PLA or ABS, and you will not require any support material while 3D printing.  The STL files to 3D print are attached on the previous blog post - Arduino Nano bot - using ultrasonic sensor

  • bottom.stl file  is used to hold the 2 DC motors, and Lipo/9V batter on the bottom and breadboard/Arduino uno/ Raspberry Pi on the top
  • top.stl file is used to hold ultrasonic sensor in the eyes, and mouth allows enough space for a USB cable to connect to Arduino Nano. In addition the holes on the top/back allows for addition sensors to be zip-tied, like a RC receiver etc..

image

 

Circuit connections

 

Here are the circuit connections using the Sparkfun motor driver(TB6612FNG) and Arduino Nano.

  • PWMA on the motor driver connected to pin# 5
  • AIN1 to pin# 4
  • AIN2 to pin# 2
  • PWMB to pin# 6
  • BIN1 to pin# 7
  • BIN2 to pin# 8
  • STBY to pin# 3

And, the RC controller receiver FLYSKY AFHDS 6 channel is connected to the Arduino Nano PWM pins

  • 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#9 on the Nano, which corresponds to pitch on the plane, but as part of this bot we will use it to control the speed and move foward and backward.
  • CH2 is connected to PWM pin#10 on the Nano, which corresponds to roll on the plane, and in this case we are going to control the bot movement from left to right.

 

image

 

 

Code to upload to the Arduino Nano

Here is the Arduino code to upload to Nano using the Arduino IDE.

 

//Project14-Nanorama- Arduino Nano bot- using RC controller sensor   


//Motor Driver Pin Connections to Arduino Nano 
int AIN1 = 4;
int AIN2 = 2;
int PWMA = 5;
int BIN1 = 7;
int BIN2 = 8;
int PWMB= 6;
int STBY = 13;
//RC controller pin connection
const int CH1 = 9;//pitch - controls foward/backward and speed
const int CH2 = 10; //roll - controls left and right


// Parameters
const int deadzone = 20;  // Anything between -20 and 20 is stop


void setup() {
  //Serial.begin(9600); 
  pinMode(STBY, OUTPUT);
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);
  pinMode(PWMA, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
  pinMode(PWMB, OUTPUT);
  
  digitalWrite(STBY, HIGH);
}


void loop() {


  // Reading channel inputs
  int x = pulseIn(CH1, HIGH, 25000);
  int y = pulseIn(CH2, HIGH, 25000);
  /*Serial.print("ch1_pitch : ");  
  Serial.println(x);  
  Serial.print("ch2_roll: ");  
  Serial.println(y);*/


  // Convert to PWM value
  y = pulseToPWM(y);
  x = pulseToPWM(x);


  // using the arcade drive algo based on https://www.youtube.com/watch?v=Bx0y1qyLHQ4
  int left = y + x;
  int right = y - x;
  drive(left, right);
  delay(5);
}




void drive(int speed_a, int speed_b) {
  // Limit speed between -255 and 255
  speed_a = constrain(speed_a, -255, 255);
  speed_b = constrain(speed_b, -255, 255);


  // Set direction for motor A
  if ( speed_a == 0 ) {
    digitalWrite(AIN1, LOW);
    digitalWrite(AIN2, LOW);
  } else if ( speed_a > 0 ) {
    digitalWrite(AIN1, HIGH);
    digitalWrite(AIN2, LOW);
  } else {
    digitalWrite(AIN1, LOW);
    digitalWrite(AIN2, HIGH);
  }


  // Set direction for motor B
  if ( speed_b == 0 ) {
    digitalWrite(BIN1, LOW);
    digitalWrite(BIN2, LOW);
  } else if ( speed_b > 0 ) {
    digitalWrite(BIN1, HIGH);
    digitalWrite(BIN2, LOW);
  } else {
    digitalWrite(BIN1, LOW);
    digitalWrite(BIN2, HIGH);
  }


  analogWrite(PWMA, abs(speed_a));
  analogWrite(PWMB, abs(speed_b));
}


// Convert RC pulse value to motor PWM value
int pulseToPWM(int pulse) {
  
  // If we're receiving numbers, convert them to motor PWM
  if ( pulse > 1000 ) {
    pulse = map(pulse, 1000, 2000, -500, 500);
    pulse = constrain(pulse, -255, 255);
  } else {
    pulse = 0;
  }


  // Anything in deadzone should stop the motor
  if ( abs(pulse) <= deadzone ) {
    pulse = 0;
  }


  return pulse;
}

if you need to to test you RC receiver connection, un-comment the code below that prints the output of one of the RC channels to the serial monitor, as you see in the picture below.

image

Add a 2 cell lipo battery to the bottom of the 3D printed part with zip ties as you see in the picture below. In my case I am using Turnigy nano-tech 460mah 2S , but a regular 9V battery will also fit the 3D printed part.

image

 

For the RC receiver you can zip tie it to the top cover as shown in the picture below. In addition once you put the lid on top of the base you can secure the base and the top cover with zip ties.

image

 

Here is a quick video of the bot in action, controlled by the RC controller.

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Previous blog post related to this project

Arduino Nano -- controlling things using a RC controllers - Servos  - this blog shows you how to control 2 servos using the same RC controller

Arduino Nano bot - using ultrasonic sensor - which is a simpler version of the bot, using the same 3D printed parts.

Attachments:
8712.NanoBot_STLfiles.zip
  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube