L O A D I N G
blog banner

Creating a remote control for Arduino-based robotic systems

Arduino is one of the best platforms to build a robotic prototypes and DIY robotic projects. Specially build in micro-controller boards, specialized sensors, easy to connect each other with wires, easy to program with Arduino programming language are major reasons of its popularity.

So, there are many Arduino based robotic systems being build on this platform. To manual control them, We need a remote controller. There are remote controllers in the market, but we can also create a remote control in the home.

First lets find about the components.

  1. Arduino Nano micro-controller board
  2. NRF24L01 frequency transmitter module with antenna(we will need the receiver module as well to implement in robotic system. )
  3. 2-joystick models
  4. Li-po battery
  5. Jumper wires
  6. PCB boards

There are two major steps in creating the remote controller.

  1. Hardware assembly
  2. programming

Following is the diagram for connecting the devices.

first lets connect the parts together. First we must connect the joystick models to PCB board and connect the wires for the ports. There are five ports in a joystick. One is Voltage port, Then ground port, and ports for the axis-control for X and Y axis. we must connect them to the mini bread board as shown in the previous figure.

every wire coming from joystick modules will connect to Arduino NANO board. Then NANO controller board will be connect to the NRF transmitter module. (Use a different colour for ports such as live wire is red colour and black wire is for the GND port).then connect the antenna to the RMF module. you can connect the battery directly into NANO board. In NANO board, there is a +5V port which connect the live(red) wire and GND port next to it which connect the ground(black ) wire. Now we have connected the parts together. We have created the remote controller.

Now. lets discuss about the programming part.

The programming of the NANO board depends on vehicle type, servo type, servo amount, etc. I have included a sample code for the device which I have been developed to control a fixed wing drone model.

#include <SPI.h>;
#include <nRF24L01.h>;
#include <RF24.h>;

const uint64_t pipeOut = 0xE9E8F0F0E1LL;   //IMPORTANT: The same as in the receiver 0xE9E8F0F0E1LL
RF24 radio(7, 8); // select CE,CSN pin

struct Signal {
  byte throttle;
  byte pitch;
  byte roll;
  byte yaw;
};
Signal Data;

void ResetData() {
  Data.throttle = 127; // Motor Stop (254/2=127)
  Data.pitch = 127; // Center 
  Data.roll = 127; // Center
  Data.yaw = 127; // Center

}

void setup() {
  // start everything up 
  radio.begin();
  radio.openWritingPipe(pipeOut);
  radio.stopListening(); // start the radio connection for transmitter
  ResetData();
}

// Joystick center and its borders:
int mapJoystickvalues(int val, int lower, int middle, int upper, bool reverse) {
  val = constrain(val, lower, upper);
  if (val < middle) {
    val = map(val, lower, middle, 0, 128);
  }
  else {
    val = map(val, middle, upper, 128, 255);
  }
  return (reverse ? 255 - val : val );

}

void loop() {
  // Control Stick Calibration:
  // Setting may be required for the correct values of the control levers:
  Data.throttle = mapJoystickvalues( analogRead(A0), 524, 524, 1015, true );
  Data.roll = mapJoystickvalues( analogRead(A1), 12, 524, 1020, true );  // "true" or "false" for servo direction 
  Data.pitch = mapJoystickvalues( analogRead(A2), 12, 524, 1020, true ); // "true" or "false" for servo direction 
  Data.yaw = mapJoystickvalues( analogRead(A3), 12, 524, 1020, true );   // "true" or "false" for servo direction 
  radio.write(&Data, sizeof(Signal));
}

As you can see we need to download following libraries to setup the program.

#include <SPI.h>;
#include <nRF24L01.h>;
#include <RF24.h>;

Then you can begin by defining pins(ports) and then create the setup and void loops. The program structure will be looked like this but the code will be changed according to what we using it for.

You May Also Like