Devices & Components
5V Power Supply Module
10kOhm potentiometer
Bread board
Arduino MKR GSM 1400 board
jumper wires for arduino
Hardware & Tools
Cardboard, markers, scissors, cutter
Software & Tools
Python IDLE
Arduino IDE
tinkercad circuits
TINKERCAD
Project description
Code
Code For DIY Car Racing Game Simulator, Made With Arduino, Potentiometer & Cardboard
cpp
Code For DIY Car Racing Game Simulator, Made With
1//Arduino Game Simulator, Play Car Racing Game 2// https://www.arduino.cc/reference/en/language/functions/usb/keyboard/keyboardmodifiers/ 3 4//Keys 5// 6//KEY_UP_ARROW 7//KEY_DOWN_ARROW 8//KEY_LEFT_ARROW 9//KEY_RIGHT_ARROW 10 11#include <Keyboard.h> 12 13float pre = 0; 14float pre_pre =0; 15float total = 300; 16int counter = 2; 17 18void setup() { 19 pinMode(A0,INPUT); 20 pinMode(A1,INPUT); 21 22// Serial.begin(9600); 23 24 Keyboard.begin(); 25 delay(10000); 26} 27 28float avg(float current){ 29 30 float ans = ((pre_pre*4)/7 + (pre*2)/7 + (current*1)/7 ); 31 pre_pre = ans; 32 pre = current; 33 34 return ans; 35} 36 37void loop() { 38 39 float acc = analogRead(A0); 40 float stear = avg(analogRead(A1)); 41 42// Serial.print(acc); 43 44// Serial.print(stear); 45// Serial.print(","); 46// Serial.println(stear); 47// delay(25); 48// /* 49 50 if(acc<500){ 51 Keyboard.release(KEY_DOWN_ARROW); 52 Keyboard.press(KEY_UP_ARROW); 53 }else if(acc>700){ 54 Keyboard.release(KEY_UP_ARROW); 55 Keyboard.press(KEY_DOWN_ARROW); 56 }else{ 57 Keyboard.release(KEY_DOWN_ARROW); 58 Keyboard.release(KEY_UP_ARROW); 59 } 60 if (stear<280){ 61 Keyboard.press(KEY_LEFT_ARROW); 62 }else if (stear>400){ 63 Keyboard.press(KEY_RIGHT_ARROW); 64 }else{ 65 Keyboard.release(KEY_LEFT_ARROW); 66 Keyboard.release(KEY_RIGHT_ARROW); 67 } 68 69// */ 70 71 72 delay(100); 73 74}
Downloadable files
STL file for the Arduino Driving Simulato game
CAD of the setup of the car simulator
Arduino Driving Simulator.stl
Documentation
Circuit diagram of the Arduino Driving Simulator
Circuit schematic of the car game simulator
Arduino Driving Simulator.pdf
Comments
Only logged in users can leave comments