Bluetooth RC receiver

4 channel Arduino Arduino UNO BlueSMiRF Bluetooth Bluetooth RC RC boat RC car RC plane RC receiver RFCOMM RoboRemo accelerometer RoboRemo slider Servo motors model RC

Build RC receiver with Arduino and control your RC car / plane / boat / etc. with RoboRemo.


arduino-bluetooth-rc-receiver.jpg

This page explains how to build an Arduino-based RC receiver to replace the original receiver in the RC car / boat / plane / etc. and control it via Bluetooth using RoboRemo app.

Materials needed:
- Arduino UNO (or similar) + USB cable for it
- BlueSMiRF module
- Android phone with RoboRemo app installed

Introduction
An RC receiver is a module that gets a radio signal (2.4GHz / 40MHz / etc.) and generates PWM signals (like the PWM that is used to control servo motors).
RC receivers look like these:
receivers.jpg

To use these receivers, you also need a remote control, that looks like this:
remotes.jpg

If you want to control your RC car / plane / boat / etc. with RoboRemo, just replace the original receiver with the Arduino RC receiver and build the RoboRemo interface as you desire.

Steps:
1.
Upload this sketch to your Arduino:

// RC receiver over Bluetooth for RoboRemo
// www.roboremo.app

// this receiver has 4 channels,
// but you can easily add more.

// Hardware setup:
// BT module   Arduino
// GND ------- GND
// VCC ------- 5V
// TX-O ------ pin0
// RX-I ------ pin1

// RC ch out     Arduino
// ch0 --------- pin4
// ch1 --------- pin5
// ch2 --------- pin6
// ch3 --------- pin7


#define bluetooth Serial
#include <Servo.h>

const int chCount = 4;

Servo ch[chCount];
int chPin[chCount] = {4, 5, 6, 7};
int chVal[chCount];

// config:
int usMin = 1000;
int usMax = 2000;



char cmd[100];
int cmdIndex;
long lastCmdTime = 60000;


boolean cmdStartsWith(char *st) {
  for(int i=0; ; i++) {
    if(st[i]==0) return true;
    if(cmd[i]==0) return false;
    if(cmd[i]!=st[i]) return false;;
  }
  return false;
}




void exeCmd() { 
  
  lastCmdTime = millis();
  
  // example: set slider id to "ch0", set min 1000 and set max 2000
  
  if( cmdStartsWith("ch") ) {
    int ch = cmd[2] - '0';
    if(ch>=0 && ch<=9 && cmd[3]==' ') {
      chVal[ch] = (int)atof(cmd+4);
    }
  }
  
  // invert channel:
  // example: set slider id to "ci0", set min -2000 and set max -1000
  
  if( cmdStartsWith("ci") ) {
    int ch = cmd[2] - '0';
    if(ch>=0 && ch<=9 && cmd[3]==' ') {
      chVal[ch] = -(int)atof(cmd+4);
    }
  }
  
  // use accelerometer:
  // example: set acc y id to "ca1"
  
  if( cmdStartsWith("ca") ) {
    int ch = cmd[2] - '0';
    if(ch>=0 && ch<=9 && cmd[3]==' ') {
      chVal[ch] = (usMax+usMin)/2 + (int)( atof(cmd+4)*51 ); // 9.8*51 = 500 => 1000 .. 2000
    }
  }
  
  // invert accelerometer:
  // example: set acc y id to "cb1"
  
  if( cmdStartsWith("cb") ) {
    int ch = cmd[2] - '0';
    if(ch>=0 && ch<=9 && cmd[3]==' ') {
      chVal[ch] = (usMax+usMin)/2 - (int)( atof(cmd+4)*51 ); // 9.8*51 = 500 => 1000 .. 2000
    }
  }
  
  // update:
  // send something that starts with "update" periodically,
  // in order to update channels
  // example: set acc x id to "update"
  
  if( cmdStartsWith("update") )
    for(int i=0; i<chCount; i++) 
      ch[i].writeMicroseconds(chVal[i]);
}



void setup() {
  
  delay(500); // wait for bluetooth module to start

  // BlueSMiRF default baud is 115200
  // For HC-05, please try 9600

  bluetooth.begin(115200); 
  
  for(int i=0; i<chCount; i++) {
    // attach channels to pins
    ch[i].attach(chPin[i], usMin, usMax);
    // initial value = middle
    chVal[i] = (usMin + usMax)/2;
    // update
    ch[i].writeMicroseconds( chVal[i] );
  }
  
  cmdIndex = 0;
}


char c = 0;


void loop() {
  
  // if contact lost for more than half second
  if(millis() - lastCmdTime > 500) {  
    for(int i=0; i<chCount; i++) {
      // set all values to middle
      ch[i].writeMicroseconds( (usMin + usMax)/2 );
    }
  }
  
  
  
  if(bluetooth.available()) {
    
    c = (char)bluetooth.read();
    
    if(c=='\n') {
      cmd[cmdIndex] = 0;
      exeCmd();  // execute the command
      cmdIndex = 0; // reset the cmdIndex
    } else {      
      cmd[cmdIndex] = c;
      if(cmdIndex<99) cmdIndex++;
    }
    
  }
  
}



2.
Connect Bluetooth module according to the hardware setup in the Arduino sketch.

3.
Replace the original receiver with your Arduino setup. Don't forget to also connect the power +5V and GND.

4.
Build the RoboRemo interface, connect via Bluetooth and enjoy :)


Share Post