Making my own PC USB racing pedal

Very green to coding, so please be kind and assume I don't know what the heck I'm doing (because I probably don't).

I've got an Arduino Uno R3 and a linear potentiometer. The goal is simple, make an analog joystick input out of the potentiometer, through the Arduino.

I've been able to get the pot hooked up, and can even get a reading between 0 and 1023 in the serial monitor. I have no clue how to get that to translate into a joystick or mouse movement. If easier than a joystick, it could be a single axis on the mouse (doesn't matter x or y).

int potPin = A1;
int potValue;
int delayTime = 100;

void setup() {
pinMode(potPin, INPUT);
Serial.begin(9600);

// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:
potValue = analogRead(potPin);
Serial.println(potValue);
delay(delayTime);

}

As you know, the potentiometer starts at 0 and travels to 1023. The joystick has two of those, and a pushbutton. The mouse counts continuous pulses created by a ball inside it, rolling in two dimensions, without a limit. You will not translate one potentiometer into either a joystick or a mouse or both.

You can make two pots into joystick by simply bolting the shafts together at 90˚ then fixing one pot body to a base and the other pot body to a stick.

Or you can reverse the idea and connect one shaft of a fixed pot to the body of the of a second pot, and then have the shaft of this second pot connected to your stick.

This not very good video shows the way of doing it, this way round:-

Note you will not get the full range of readings for this arrangement, but by careful use of the map function and some other code you can correct the reading you get to 0 to X which will get you toa useful range.

Or simply buy a joystick they are not very expensive.

The important thing is to choose a model of Arduino that has "native USB" like Pro Micro (don't confuse with Pro Mini) or Leonardo.

In theory it can also be done with Uno/Mega but this is significantly more difficult and risky, and not for beginners.

Please always use code tags when posting code. Read the forum guide in the sticky post at the top of most forum sections to find out how and other forum rules.

I am not trying to make a joystick, I'm trying to make an accelerator pedal. Thus, all I need is one axis.

I see. A potentiometer will work for making an accelerator pedal. Your writing confused me when you wrote;

Me too.

@tommc714

I see you still haven't posted your code correctly using code tags.

You might want to look at this How to get the best out of this forum before you proceed any further.
We only know what you tell us, and without knowing what you have, we don't stand a chance.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.