Suyash Sonkesaria
Published

Real World Driving Simulator For Any Game & Physical Vehicle

It can be used to play car racing games or experience driving a real car. It can be used to drive an RC car using real controls.

IntermediateWork in progress209
Real World Driving Simulator For Any Game & Physical Vehicle

Things used in this project

Hardware components

Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Coral Dev Board
Google Coral Dev Board
×1
Arduino MKR GSM 1400
Arduino MKR GSM 1400
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
9V 1A Switching Wall Power Supply
9V 1A Switching Wall Power Supply
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1

Hand tools and fabrication machines

Scissor, Electrician
Scissor, Electrician
Tape, Electrical
Tape, Electrical
Multitool, Screwdriver
Multitool, Screwdriver
Soldering iron (generic)
Soldering iron (generic)
Hot glue gun (generic)
Hot glue gun (generic)
Breadboard, 270 Pin
Breadboard, 270 Pin

Story

Read more

Custom parts and enclosures

CAD Design of the simulator

Schematics

Circuit Schematic

Code

Code of Driving simulator

Arduino
//Arduino Game Simulator, Play Car Racing Game
// https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardmodifiers/

//Keys 
//
//KEY_UP_ARROW
//KEY_DOWN_ARROW
//KEY_LEFT_ARROW
//KEY_RIGHT_ARROW

#include <Keyboard.h>

float pre = 0;
float pre_pre =0;
float total = 300;
int counter = 2;

void setup() {
  pinMode(A0,INPUT);
  pinMode(A1,INPUT); 
  
//  Serial.begin(9600);

  Keyboard.begin(); 
  delay(10000);
}

float avg(float current){
  
  float ans = ((pre_pre*4)/7 + (pre*2)/7 + (current*1)/7 );
  pre_pre = ans;
  pre = current; 
  
  return ans;
}

void loop() {
  
  float acc = analogRead(A0);
  float stear = avg(analogRead(A1));
  
//  Serial.print(acc);
  
//  Serial.print(stear);
//  Serial.print(",");
//  Serial.println(stear);
//  delay(25);
//  /*

  if(acc<500){
    Keyboard.release(KEY_DOWN_ARROW);
    Keyboard.press(KEY_UP_ARROW);
  }else if(acc>700){
    Keyboard.release(KEY_UP_ARROW);
    Keyboard.press(KEY_DOWN_ARROW);
  }else{
      Keyboard.release(KEY_DOWN_ARROW);
      Keyboard.release(KEY_UP_ARROW);
  }
  if (stear<280){
    Keyboard.press(KEY_LEFT_ARROW);
  }else if (stear>400){
    Keyboard.press(KEY_RIGHT_ARROW);
  }else{
      Keyboard.release(KEY_LEFT_ARROW);
      Keyboard.release(KEY_RIGHT_ARROW);
  }
  
//  */


  delay(100);

}

Credits

Suyash Sonkesaria

Suyash Sonkesaria

1 project • 0 followers

Comments