Help programming an analog hall effect sensor as a game controller

Hi

I'm building a handbrake for my sim racing rig and need help with the code as i can't actually code myself.

These are the 2 parts i'm using

and

First i compiled and uploaded this sketch

//Analog Hall Sensor
//using an LM393 Low Power Low Offset Voltage Dual Comparator
/*******************************

  • Analog Hall Sensor Uno R3
  • A0 A0
  • D0 7
  • VCC 5V
  • GND GND
    *******************************/

const int ledPin = 13;//the led attach to pin13
int sensorPin = A0; // select the input pin for the potentiometer
int digitalPin=7; //D0 attach to pin7

int sensorValue = 0;// variable to store the value coming from A0
boolean digitalValue=0;// variable to store the value coming from pin7

void setup()
{
pinMode(digitalPin,INPUT);//set the state of D0 as INPUT
pinMode(ledPin,OUTPUT);//set the state of pin13 as OUTPUT
Serial.begin(9600); // initialize serial communications at 9600 bps

}

void loop()
{
sensorValue = analogRead(sensorPin); //read the value of A0
digitalValue=digitalRead(digitalPin); //read the value of D0
Serial.print("Sensor Value "); // print label to serial monitor
Serial.println(sensorValue); //print the value of A0
Serial.print("Digital Value "); // print label to serial monitor
Serial.println(digitalValue); //print the value of D0 in the serial
if( digitalValue==HIGH )//if the value of D0 is HIGH
{
digitalWrite(ledPin,LOW);//turn off the led
}
if( digitalValue==LOW)//else
{
digitalWrite(ledPin,HIGH);//turn on the led
}
delay(1000);//delay 200ms
}

And i can get a readout on the serial monitor.

I then installed the joystick library and ran the test code and i can see windows is recognising the arduino as a game controller.

I need windows to recognise the analog hall sensor as a throttle, and be plug and play so i don't have to mess about when starting a game. I think i'll also need the ability to adjust the range.

Can anyone help?

You're off to a good start with your first post, here are a couple of finer detail points. Make your links clickable so people can see your references without cutting and pasting, a real PIA on tablets and other small devices. Use the clickable icon with the link symbol or learn how to insert the tags manually.

When posting code, use code tags so the forum software doesn't eat characters and makes it easy for people to duplicate your code for testing. Use the icon with the <> characters.

Lastest, with respect to your specific request: try Googling "Arduino Leonard game controller" and you'll find the answers to your questions, it's been done before, more than once.

Thanks Fred. I think that's the most helpful response I've ever had to a question. ;D

Hi I've seen your post on a few other forms regarding the same question I have the same parts and I was able to get it recognized as a controller with the same Joy test and also the code you have posted above but how do I get them both to work at the same time in tandem to recognize as a game controller end have the hall sensor effect work?