Problems in analog input (newbie)

I'm really sorry to write but I have a problem that I cannot solve

Starting from the standard libraries for a Joystick I added an analog input from a pot, but I have to trim the signal at around 400 instead of the normal 1023.

I tried to trim it alone, programming the board with just the pot input and it worked... as soon as I add that part into the whole code of the Joystick, even if I use the constrain function, the output goes still from 0 to 1023

Do I probably miss something? :cry:

#include <Joystick.h>

Joystick_ Joystick;

void setup() {
  // Initialize Button Pins
  pinMode(9, INPUT_PULLUP);
  pinMode(10, INPUT_PULLUP);
  pinMode(11, INPUT_PULLUP);
  pinMode(12, INPUT_PULLUP);
  pinMode(A0, INPUT);

  // Initialize Joystick Library
  Joystick.begin();
}

// Constant that maps the phyical pin to the joystick button.
const int pinToButtonMap = 9;

// Last state of the button
int lastButtonState[4] = {0,0,0,0};

void loop() {


{int pot = analogRead(A0);
pot=constrain(pot, 0, 460);
int mapped = map(pot,0,460,0,255);
{Joystick.setThrottle(mapped);}}


  // Read pin values
  for (int index = 0; index < 4; index++)
  {
    int currentButtonState = !digitalRead(index + pinToButtonMap);
    if (currentButtonState != lastButtonState[index])
    {
      Joystick.setButton(index, currentButtonState);
      lastButtonState[index] = currentButtonState;
    }
  }

  delay(50);
}
{int pot = analogRead(A0);

pot=constrain(pot, 0, 460);
int mapped = map(pot,0,460,0,255);
{Joystick.setThrottle(mapped);}}

The extra { and } here are creating "blocks" of code which keep the internal variables private inside the block. No other code outside of this block can access the variables pot or mapped.

Remember map doesn't constrain. If the input goes off the end of the input values then the output will exceed the mapped output values.