Jonathan Loong
Published © GPL3+

Vintage RC Car Joystick

Making an Arduino-powered vintage RC car joystick!

IntermediateWork in progress111
Vintage RC Car Joystick

Things used in this project

Hardware components

Vintage Joystick
×1
SparkFun ardiuno protoshield
×1
Plastic Enclosure, Project Box
Plastic Enclosure, Project Box
×1
Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
5 mm LED: Red
5 mm LED: Red
×1
D Sub Connector, DB15
D Sub Connector, DB15
×1
LED Holder, 7.6 mm x 13.9 mm
LED Holder, 7.6 mm x 13.9 mm
×1
915 MHz radio module
×1
Toggle Switch, Toggle
Toggle Switch, Toggle
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Basic Arduino Schematic

This is to interface with the vintage joystick and provide basic IO and serial connections

Code

RC Transmitter

Arduino
Arduino interfacing with ADC and IO for button on joystick. Serial port used to send control data to the RC car

References:
http://www.built-to-spec.com/blog/2009/09/10/using-a-pc-joystick-with-the-arduino/
https://old.pinouts.ru/InputCables/GameportPC_pinout.shtml
https://baremetalmicro.com/tutorial_avr_digital_io/04-Outputs.html
/*

Driver to send vintage joystick inputs to 915 MHz telemetry link
to send to RC car

*/

//#define DEBUG_MODE //debug_mode shows raw ADC 
#define STEER_ADC A0
#define THROTTLE_ADC A3
#define LED 10
#define TRIGGER 2
#define BLINK_TIME 250
#define BUTTON 7

char tx_array[24] = {};
unsigned long blink_ctr = 0;

#define MOVING_AVG_FILTER_NUM 5
int smooth_array_steer[MOVING_AVG_FILTER_NUM];
int smooth_array_throttle[MOVING_AVG_FILTER_NUM];
int index_steer = 0;
int sum_steer = 0;
int index_throttle = 0;
int sum_throttle = 0;
int smooth_steer = 0;
int smooth_throttle = 0;

void setup()
{

  Serial.begin(57600);
  pinMode(STEER_ADC,INPUT);
  pinMode(THROTTLE_ADC,INPUT);
  pinMode(LED,OUTPUT);
  pinMode(TRIGGER,INPUT);
  pinMode(BUTTON,INPUT);
}

int mapVal(int curr_val, int minIn, int maxIn, int minOut, int maxOut)
{
  return (minOut + ((maxOut - minOut) / (maxIn - minIn) * (curr_val - minIn)));
}

// ADC (steer)
int tx_steer()
{
  return mapVal(analogRead(STEER_ADC),960,670,1000,2000);
}

// moving average filter for ADC (throttle)
int tx_throttle()
{
  sum_throttle = sum_throttle - smooth_array_throttle[index_throttle];
  uint8_t temp_value = analogRead(THROTTLE_ADC);
  smooth_array_throttle[index_throttle] = temp_value;
  sum_throttle += temp_value;
  index_throttle = (index_throttle+1) % MOVING_AVG_FILTER_NUM;
  smooth_throttle = sum_throttle / MOVING_AVG_FILTER_NUM;
  int converted_throttle = mapVal(smooth_throttle,27,252,1000,1240);
  if (converted_throttle > 1200) return 1200;
  else return converted_throttle;
}

void loop()
{
  
  if (digitalRead(TRIGGER) == LOW)
  {
    if (millis() - blink_ctr > BLINK_TIME)
    {
      blink_ctr = millis();
      digitalWrite(LED,HIGH);     
    }
    else
    {
      digitalWrite(LED,LOW);
    }
     
    #ifdef DEBUG_MODE
      sprintf(tx_array,"T: %d S: %d\n",analogRead(THROTTLE_ADC),analogRead(STEER_ADC));
    #else
      sprintf(tx_array,"%d,%d#\n",tx_throttle(),tx_steer());
    #endif
  }
  else
  {
    sprintf(tx_array,"%d,%d#\n",990,1500);
  }
  Serial.print(tx_array);    
  delay(50);  
}

Credits

Jonathan Loong

Jonathan Loong

0 projects • 0 followers
Mechatronics Engineer | UAV Enthusiast

Comments

Add projectSign up / Login