Hackster is hosting Hackster Holidays, Ep. 4: Livestream & Giveaway Drawing. Start streaming on Wednesday!Stream Hackster Holidays, Ep. 4 on Wednesday!
eruiec11
Published

Connect any RC Transmitter with RC Simulator

Use any RC transmitter and receiver with an RC flight simulator using Arduino Uno and UnoJoy.

IntermediateFull instructions provided8,144
Connect any RC Transmitter with RC Simulator

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
RC receiver
Example of an RC receiver
×1
RC transmitter
Example of an RC transmitter
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

RC receiver connected to Arduino

Signal wires from the RC receiver are connected to the Arduino digital pins

Code

Processing receiver signals

C/C++
#include "UnoJoy.h"

//Declaring a channel variable 
int channel_1;
int channel_2;
int channel_3;
int channel_4;

int ch1;
int ch2;
int ch3;
int ch4;


void setup(){
  setupPins();
  setupUnoJoy();
  
}

void loop(){

  //Getting fresh data
  dataForController_t controllerData = getControllerData();
  setControllerData(controllerData);

  
}

void setupPins(void){
  //Setting all the digital pins as inputs with the pull-up enabled
  for (int i = 2; i <= 12; i++){
    pinMode(i, INPUT);
    digitalWrite(i, HIGH);
  }
}

dataForController_t getControllerData(void){
  
  //Useing the getBlankDataForController() function to set up a place for the controller data. 
  dataForController_t controllerData = getBlankDataForController();
  
  //Reading the pulse duration from pins
  channel_1 = pulseIn (2, HIGH);
  channel_2 = pulseIn (3, HIGH);
  channel_3 = pulseIn (4, HIGH);
  channel_4 = pulseIn (5, HIGH);

  //Limitation of the pulse duration and the conversion to an 8 bit number
  ch1 = map(constrain(channel_1, 1000, 2000), 1000, 2000, 0, 255);
  ch2 = map(constrain(channel_2, 1000, 2000), 1000, 2000, 0, 255);
  ch3 = map(constrain(channel_3, 1000, 2000), 1000, 2000, 0, 255);
  ch4 = map(constrain(channel_4, 1000, 2000), 1000, 2000, 0, 255);
 
  //Setting the controller sticks
  controllerData.leftStickX = ch1;
  controllerData.leftStickY = ch2;
  controllerData.rightStickX = ch3;
  controllerData.rightStickY = ch4;
  //Returning the data
  return controllerData;
}

Credits

eruiec11

eruiec11

0 projects • 1 follower

Comments