DIY steering wheel

hello i am new to arduino, i want to build a DIY steering wheel on LEONARDO with potentio only(10k)(for steering and paddles ) and with switch for sifters . i saw some you tube videos where they use Roatry encoder , and using pot for paddles , i try once only with a pot for steering wheel(x axis) with code:

#include "Joystick.h"

// Create Joystick
Joystick_ Joystick;


void setup() {

Joystick.begin();
Joystick.setXAxisRange(-127, 127);
pinMode(A0, INPUT_PULLUP);


}

void loop() {

int pot1 = analogRead(A0);
Joystick.setXAxis(pot1);  


}

but as i m new to this field i don't know how to add 5 more push buttons/limit switches for sifter and other break,accelerator , using pot also

this firmware is nice with rotary encoder but as i cant get one encoder so i cant use this or i dont have codes for this firmware only hex is available so i cant edit it also for my own use. can anyone guide me how i can do this i mean how i can use 4 pot (wheel and paddles) and 6 switch for sifter?

firmware i m talking about is : here
loader :here
wheel config :config exe

this is the image from original post where they use rotary encoder (from printer)


and this is the post : Forum

All i just want to use a potentiometer as encoder for steering wheel .THANKS :slight_smile:

The general purpose of the forum is for you to post your code, with errors if any, and some indication as to where you think the problem is. Having done that, others may examine where you need to consider consider making changes to achieve your desired goal.

By posting a copy of a wiring diagram together with links to component modules, you are effectively asking to have your code written for you. That is inconsistent with the nature of this forum and seriously derails the learning process. Give it your best shot and come back with a bit more than just a constructor and a variable.

If you would like someone to write code for you, there are many sites that cater to those requirements.

#include "Joystick.h"

// Create Joystick
Joystick_ Joystick;

void setup() {
pinMode(9, INPUT_PULLUP);
pinMode(10, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
pinMode(12, INPUT_PULLUP);
Joystick.begin();
Joystick.setXAxisRange(0, 1023);
pinMode(A0, INPUT_PULLUP);

}
const int pinToButtonMap = 9;

// Last state of the button
int lastButtonState[4] = {0,0,0,0};
void loop() {

int pot1 = analogRead(A0);
Joystick.setXAxis(pot1);

for (int index = 0; index < 4; index++)
{
int currentButtonState = !digitalRead(index + pinToButtonMap);
if (currentButtonState != lastButtonState[index])
{
Joystick.setButton(index, currentButtonState);
lastButtonState[index] = currentButtonState;
}
}

delay(50);
}

where can i find joystick.h ?

Heard of Google? took 5 seconds. :slight_smile: