Having a problem with unojoy

Hey:D

so im trying to use a pressure sensor with a analog sensor in a game.
it has 1000 psi.
the pressure sensor is screwed into my handbrake which i want to use in racing games.
Im using a elegoo uno r3, I already got it working as a controller with unojoy.
So my problem is that when the lever of the handbrake is not pulled it has 94 psi and when its fully pulled it has 102 psi. how can i get it to work that when it isnt pulled it is at 0% and when its fully pulled its at 100%? i already tried it like this: controllerData.rightStickY = map( analogRead(A3), 94, 102, 0, 1023) >> 2; . but it didnt work. The Controller is just going crazy with the axis. Please help.

I’m not sure I get your description: what does analogRead(A3) return? what do you get there? directly PSI measure?

map works that way: map(value, fromLow, fromHigh, toLow, toHigh)

so map( analogRead(A3), 94, 102, 0, 1023) would take something in between 94 and 102 and transform it into something between 0 and 1023 (using integer calculation so given the short range of the input you’ll get not too many levels)

and what is your >> 2 for? this is multiplying by 4 the output so you are getting a value between 0 and 4092

<EDIT divide by 4 not multiply !! Just map to 0-255>

if you want to map 0 - 1023 that your AnalogRead() might returns into 94PSI to 102PSI, then you need to do map(analogRead(A3), 0, 1023, 94, 102)

If the full range of control only gives 8 steps you will have trouble mapping that smoothly to a 0-255 range. An analog input of 102 means your highest voltage is about 0.5V. I would suggest trying the internal 1.1V analog reference. That should get you almost 5 times the resolution or about 40 steps.

https://www.arduino.cc/en/Reference/AnalogReference

It's kind of silly to map() your input range to an output range of 0-1023 only to divide by 4 to get a 0-255 range. Map directly. Be warned that map() doesn't do limit checking. If your input goes over the high value your output will go over the high value. If you get to 256 and throw away all but the bottom byte you will end up at 0! I would add a constrain() to keep the outputs in range:

controllerData.rightStickY = constrain(map(analogRead(A3), 427, 463, 0, 255), 0, 255);

You can’t use the internal analogReference unless the pressure sensor outputs something in the 0-1volt range.
Post a link to the sensor, and a picture or diagram how it is connected.
Leo…

Hey so thanks for the answer:) im Not a Pro at programming so i dont really understand anything:D
It would be awesome if someone could give me a step by step Tutorial. Ill explain what i want to so again.
So i want to use a Hydraulik handbrake to Play racing games. If Got my 1000 psi Sensor screwed into my hydro hamdbrake. The arduino must bei recognized as a Controller to work in games (Unojoy). If i dont pull the handbrake i dont want it to be at 0% at the axis and if i pull the handbrake Back all the way i want the axis to be at 100%. Someone please give me a step by step Tutorial.