2 axis analog joystick

Hi, I am trying to figure out how to get my leonardo to work as a joystick using an x and y analog input from a joystick module I don't have any code to post cause I am kind of lost where to start.

I have been following this indestructible and using the joystick library included in the guide.

Squint.

How far did you get in following that Instructable? Did you install the library? Did you upload the test sketch? Did you get any input into the PC?

Yep installed library, examples work, just unsure about how to get the joystick pots to send analog signals to my computer.

void loop() {
    Joystick.setXAxis(analogRead(A0)/4);
    Joystick.setYAxis(analogRead(A1)/4);
}

Thanks, I'll give it a try. just wondering what does the /4); do?

Divides by 4, truncating to an integer result.

Dividing by 4 converts the 10-bit output range of analogRead() to match the 8-bit input range of Joystick.setXAxis(). Could also be written as '>>2' (shift right logical by 2 bits).

Ahhh I see, thanks a lot for the help, my project is working now and almost done, the joystick has very high sensitivity though is there a way of changing the sensitivity through ardurino and/or create a deadzone for the centerpoint? I have tried calibrating it through windows which has helped find the centerpoint but it's still unreliable at the moment.

is there a way of changing the sensitivity through ardurino and/or create a deadzone for the centerpoint?

You really need to post the arduino code for that answer.

#include <Joystick.h>

void setup() {
  pinMode(7, OUTPUT);
  pinMode(9, INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP);
  pinMode(11, INPUT_PULLUP);
  pinMode(12, INPUT_PULLUP);
  Joystick.begin();
}

const int pinToButtonMap = 9;
int lastButtonState[4] = {0,0,0,0};

void loop() {

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

  delay(25);
}

update sensitivity was fine it was just off center I fixed it by changing this:

Joystick.setXAxis(analogRead(A0)/4);
    Joystick.setYAxis(analogRead(A1)/4);

to this:

Joystick.setXAxis(analogRead(A0)/4 +126);
    Joystick.setYAxis(analogRead(A1)/4 +126);

All done and working thanks for the help!