I am using the Game Control Plus library in processing. I have setup a configuration for the joystick and mapped one button to “TRIM”. Processing is reading button presses correctly. The code below runs and the Arduino will trigger the relay with my If/Else command if I switch it back and forth. I cannot get the input from the joystick to trigger the relay. I have watched the Game Control Plus videos and looked through the Examples and haven’t been able to figure this out. Running the Arduino Out Exapmle and using the mouse to trigger the relays works. Any help would be appreciated.
Hi @01G8R, You are welcome here and I’m sorry no-one has replied. I’ve never used the Game Control library. “Joystick…relay” - Can you think of that as two separate steps: Joystick to Processing and Processing to Arduino? Are you able to get Processing to print the state of the Joystick?
Just noticed this discussion so sorry in not replying earlier.
The first thing to do is check whether Processing is detecting the joystick-button press. Modify the user input function to
public void getUserInput() {
trim = vkb.getButton(“TRIM”).pressed();
println("TRIM pressed " + trim);
}
When you run the sketch does it flip between true and false when you press and release the button?
If it does then the problem is in how you process the input.
I noticed in the draw() method the following statement
if (trim)
arduino.digitalWrite(10, Arduino.LOW);
else
arduino.digitalWrite(10, Arduino.HIGH);
So trim is true when the button is pressed and false otherwise. Now draw() is executed approximately 60 times a second so when you press and release the button trim is only true for a fraction of a second so the statement arduino.digitalWrite(10, Arduino.HIGH); is executed almost all the time so it will appear that the button has not been pressed.
Sorry for the late response here, Im running into a similar issue with my current setup and I cant get my LED to turn on with my PS4 controller. Im wondering what you did to fix your code? Thanks!