I'm using a "JoyStick Breakout Module Shield For PS2 Game Controller For Arduino" that you can easilly find on ebay.
I always get a HIGH value when I'm trying to read the button state...
Here a simplified code to understand:
const int joy_z = 6;
void setup()
{
pinMode(joy_z, INPUT);
//pinMode(joy_z, INPUT_PULLUP); also tried this option but it doesn't change anything
}
loop {
value = analogRead(joy_z); //Return a value > 0 when button unpressed and value = 0 when button pressed
value = digitalRead(joy_z); //Always return HIGH
delay(700);
}
I was expecting to use digitalRead method to read the button pressed state.
the variable "value" is never declared is it a "byte' or an "int" or?
//Return a value > 0 when button unpressed and value = 0 when button pressed
this doesn't make sense for a analogRead.
the x and y axis require only analogRead
the z axis is a button and so requires only digitalRead.
const int joy_z = 6;
int value; // needed to declare this
void setup()
{
pinMode(joy_z, INPUT_PULLUP);
}
void loop() {
value = digitalRead(joy_z); // this is the only read needed
delay(700);
}