Arduino Steering Wheel

Hi, I recently started the realization of a steering wheel with 10 keys and pedal using Arduino Pro Micro but are totally inexperienced with Arduino's programming. Can anyone kindly help me?
15 Replies
(°͡ ʖ͜ °͡ )0ㄣ9¯ʎɹol
i need help by i warn yow i don't know nothing of coding an arduino
Maverick
Maverick2mo ago
You can find a simple steering wheel project here: https://github.com/TechKyleYT/ArduinoSteerWheel
(°͡ ʖ͜ °͡ )0ㄣ9¯ʎɹol
thanks but if i need to connect a pedalboard diy?
Maverick
Maverick2mo ago
The code for the pedal would be similar to the code for the steering wheel. An analog input.
(°͡ ʖ͜ °͡ )0ㄣ9¯ʎɹol
#include <Joystick.h> Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_JOYSTICK, 0, // button count 0, // hat switch count true, // X axis true, // Y axis false, // Z axis false, // Rx axis false, // Ry axis false, // Rz axis true, // throttle true, // brake true); // clutch int throttlePin = A1; // acceleratore int brakePin = A2; // freno int clutchPin = A3; // frizione (opzionale) int xVal = 0; int potPin = A0; double xAxis = 0; float multiplier = 1.4; void setup() { Joystick.setXAxisRange(-127, 127); Joystick.setYAxisRange(-127, 127); Joystick.begin(); //Serial.begin(9600); } void loop() { // --- Volante (asse X) xVal = analogRead(potPin); xAxis = ((0.24828934506 * xVal) - 127) * multiplier; if (xAxis < -127) xAxis = -127; else if (xAxis > 127) xAxis = 127; // --- Pedali (acceleratore, freno, frizione) int throttleVal = analogRead(throttlePin); int brakeVal = analogRead(brakePin); int clutchVal = analogRead(clutchPin); int throttle = map(throttleVal, 0, 1023, 0, 255); int brake = map(brakeVal, 0, 1023, 0, 255); int clutch = map(clutchVal, 0, 1023, 0, 255); // --- Invio valori al PC Joystick.setXAxis(xAxis); Joystick.setYAxis(0); Joystick.setThrottle(throttle); Joystick.setBrake(brake); Joystick.setRudder(clutch); // uso Rudder per la frizione Joystick.sendState(); } this code is right?
Maverick
Maverick2mo ago
No, the semicolon and closing parenthesis for the joystick constructor is commented out. Also, I don't think the joystick library has functions like "setBrake" or "setRudder".
(°͡ ʖ͜ °͡ )0ㄣ9¯ʎɹol
how do i make it work?
Maverick
Maverick2mo ago
Correct the issues mentioned above, to start.
(°͡ ʖ͜ °͡ )0ㄣ9¯ʎɹol
#include <Joystick.h> // Usa Z, Rx, Ry per throttle, brake, clutch Joystick_ Joystick(JOYSTICK_DEFAULT_REPORT_ID, JOYSTICK_TYPE_JOYSTICK, 0, // button count 0, // hat switch count true, // X axis false, // Y axis true, // Z axis -> Throttle true, // Rx axis -> Brake true, // Ry axis -> Clutch false, // Rz axis false, // rudder false, // throttle (vecchio) false // accelerator (vecchio) ); int potPin = A0; // volante int throttlePin = A1; // acceleratore int brakePin = A2; // freno int clutchPin = A3; // frizione void setup() { Joystick.setXAxisRange(-127, 127); Joystick.setZAxisRange(0, 255); // throttle Joystick.setRxAxisRange(0, 255); // brake Joystick.setRyAxisRange(0, 255); // clutch Joystick.begin(); } void loop() { // Volante int xVal = analogRead(potPin); double xAxis = ((0.24828934506 * xVal) - 127) * 1.4; xAxis = constrain(xAxis, -127, 127); Joystick.setXAxis(xAxis); // Pedali int throttle = map(analogRead(throttlePin), 0, 1023, 0, 255); int brake = map(analogRead(brakePin), 0, 1023, 0, 255); int clutch = map(analogRead(clutchPin), 0, 1023, 0, 255); Joystick.setZAxis(throttle); Joystick.setRxAxis(brake); Joystick.setRyAxis(clutch); Joystick.sendState(); } now it's correct? i used chat gpt to correct it because i don't know anything about programming an arduino
Maverick
Maverick2mo ago
No, it does not look correct. Look at the library examples rather than using a chat bot. Here is a good example: https://github.com/bsmr/MHeironimus-ArduinoJoystickLibrary/blob/master/Joystick/examples/MultipleJoystickTest/MultipleJoystickTest.ino If you have no experience at all, start with the basics. Learn how to blink an LED, how to write basic code, etc. Then, come back to this later.
(°͡ ʖ͜ °͡ )0ㄣ9¯ʎɹol
but i'm creating a steering wheel with pedals and i really nead this code. What can i do for this/
Maverick
Maverick2mo ago
If you want to write the code yourself, you will have to learn. The example I posted is a good example for what you're trying to do. It handles multiple joysticks which is the same as wheel, brake, throttle.
(°͡ ʖ͜ °͡ )0ㄣ9¯ʎɹol
But I can copy and paste the code you link?
Maverick
Maverick2mo ago
No, but you can learn from it.
(°͡ ʖ͜ °͡ )0ㄣ9¯ʎɹol
Ok, thanks

Did you find this page helpful?