Arduino Leonardo steering wheel one axis

Hello :slight_smile:
today i got my arduino leonardo and i want to make steering wheel using potentiometers, but since i dont have full "equipment" but only 1 potentiometer, for beggining i want to make only 1 axis joystick, (x axis or whatever is needed for steering in PC GAMES like euro truck simulaotr 2), i tried codes on internet but i had issues with them like deadzones and so. i think that is because i have only 1 potentiometer but those codes are intended for steering, breaking, force feedback and so..., and because im full noob,scrub with arduino i need help with making single axis controller

i need help with making single axis controller

Step 1: Connect the potentiometer to the Arduino. How did you do that?

Step 2: Read the potentiometer value using analogRead() and the appropriate pin. What pin did you use, and what kind of readings did you get?

Step 3: Use the data for some purpose. Specifically, what purpose did you have in mind, and how did you use the data?

i connected potentiometer 10k ohm (300°) with 3 pins(idk how to call them), left pin is connected to VCC, second pin (slider) to A1 and third pin is connected to GND, and i want to controll steering vehicle in game (ets2) with that one potentiometer and since im complete dummy with programming arduino i really dont know how to use data for steering input

So, you completed Step 1 correctly.

Step 2 is trivial.

int potVal = analogRead(1);

Step 3 is going to be the hard part. The application that you want to send the data to expects some range of values (perhaps -255 to 255 or 0 to 512 or something else) in some format. You need to determine what range of values it expects, in what format. That is not a programming issue, per se, since the research is required regardless of which programming language you are using and regardless of which computer you are programming on.

im "programming" on arduino program 1.8.3 which i downloaded from this site

cr0wl:
im "programming" on arduino program 1.8.3 which i downloaded from this site

That is not what @PaulS was trying to say.

You need to know what data the application you want to control requires as input. We don't know that - you have to find it out. If the Arduino sends (say) 134 when the application requires (say) -456 nothing is going to work.

...R

i have no idea what are you guys talking about (sry im very new) :frowning:
i just want to use it as single axis joystick (left and right) without up and down if it helps

I have the impression you want to use the steering wheel as an input to some PC game?

Is that correct?

if so, what game?

...R

exactly i want to use it as steering wheel for Euro Truck Simulator 2
im really sorry if im bothering you but im very new in this and i dont know a single thing

i want to use it as steering wheel for Euro Truck Simulator 2

So, YOU need to determine exactly what this software expects to show up on the serial port, to actually control anything. Is it expecting binary data or ASCII? What range of values?

cr0wl:
exactly i want to use it as steering wheel for Euro Truck Simulator 2

As @PaulS says you need to find out what data is required by Euro Truck Simulator 2 for the steering wheel to work. If there is a datasheet or user manual that explains that then post a link to it.

...R

Could this maybe help?

I don't think that link is useful. It seems to be written on the assumption that you are using a specific piece of hardware "Logitech G27 and compatible wheels"

What you need to know is how to program your Leonardo to pretend it is a Logitech G27.

And I have no idea whether that is easy to do or very very complicated.

...R

Try this just for an idea, I don't have your game software or hardware. Good luck.

void setup()
{
  Serial.begin(9600); // set Serial monitor to match
}
void loop()
{
  int val = analogRead(A1);
  if(val > 506 && val < 516)
  {
   Serial.print("  Straight ahead  ");
   Serial.println(val - 511);
  }
  else if(val > 516)
  {
   Serial.print("  Turning Right ");
   Serial.println(val - 511);
  }
  else if(val < 506)
  {
   Serial.print("  Turning Left ");
   Serial.println(val - 511);
  }
  delay(300);  
}

@edgemoron that worked in serial monitor :slight_smile:

but guys can i not just turn my leonardo into a simple joystick?

Well, that sketch is just a demo of getting pot (or joystick) data from an analog input, now, getting that data from your Leo into your game computer is a whole different thing, sorry but I have no idea. :confused:

cr0wl:
but guys can i not just turn my leonardo into a simple joystick?

You have to know how the "simple joystick" interacts with your PC. That is probably not simple. The interaction between a USB peripheral and a PC is certainly not simple. For one thing there needs to be a complex set of signals to tell the PC what sort of peripheral it is before anything useful can happen.

You can easily make a Leonardo behave as a keyboard or a mouse.

...R

Hi i m trying to work with the same idea making a controller for ets2 i want to know if you get to any point.i found unojoy but couldnt work for me.