"If the pin is configured as an INPUT , digitalWrite() will enable (HIGH ) or disable (LOW ) the internal pullup on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor. See the Digital Pins tutorial for more information."
Is it the loop() function that you want to start once the button is pressed ? If so then read its state in setup() and only leave setup() once the button is pressed
If you are trying to do something else then please explain in more detail
But once you read it you ignore it's state and setup() ends
On a more general matter, I suggest that you use INPUT_PULLUP in pinMode instead of writing HIGH after using INPUT to turn on the internal pullup resistor as it is so much more obvious what you are doing
Your code is now in a real mess I am afraid, but it can be fixed
Let's start with the basics. If I remember correctly from another of your topics the button is connected between the pin (it was a different pin in the other topic) and GND so the pin will go LOW when the button is pressed, hence the use of INPUT_PULLUP to turn on the built in pullup resistor, but you do that in pinMode(), not with digitalWrite()
With that in mind, here is the corrected code up to the end of setup()
const int Joystick_X = A0;
const int Joystick_Y = A1;
const int pushbutton = 3;
int JoystickValue_X = 0;
int JoystickValue_Y = 0;
int pushbuttonState;
void setup()
{
pinMode(Joystick_X, INPUT); // X-axis
pinMode(Joystick_Y, INPUT); // Y-axis
pinMode(pushbutton, INPUT_PULLUP); // press button
Serial.begin(9600);
while (digitalRead(pushbutton) == HIGH);
}
Once you press the button the loop() function will start. In loop() there is no need to test the value of pushbuttonState unless you want the button to make the code do something else so you could just write
Yeah I think so, if I understand correctly the Joystick Input_Pullup gives the joystick constantly the state of being HIGH, so as long as the button is unpressed it will stay in void setup()
If I press the button it will go to void loop and I dont need to redefine the state as it is already in the loop