Game Control Plus

edited March 2018 in Arduino

Hello! I am new to processing and to this forum so hi everybody! I am trying to make a code that will post 1,2 or 3 on the serial interface of a arduino. It should send the numbers when i pres some buttons on the controller but the code doesn't work! Keep in mind that the code is intended for just one button at the time! Here is the code:

`import processing.serial.*; import org.gamecontrolplus.gui.*; import org.gamecontrolplus.*; import*;

Serial myPort;

ControlIO control; ControlDevice device; void setup() { size(400, 400); control = ControlIO.getInstance(this); device = control.getMatchedDevice("leds"); String portName = Serial.list()[2]; myPort = new Serial(this, portName, 9600); } void draw() { size(1, 1); if (device.getButton("Button1").pressed() == true); { //if we clicked in the window myPort.write('1'); } }`

And here is the config file made with the configurator example sketch from the library!

Lighting Leds Red Light up the red Led 1 BUTTON Button 1 0 0.0 0.0 Green Light up the green Led 1 BUTTON Button 0 0 0.0 0.0 Blue Light up the blue Led 1 BUTTON Button 2 0 0.0 0.0



  • In the code you have device.getButton("Button1").pressed() but there is no input called "Button1" the device has a button called "Button 1" but the whole point of creating the configuration file is that we create aliases for the inputs.

    What it should be is device.getButton("Red").pressed()

    When using this library I suggest that you create a simple demo sketch without Arduino to make sure the configuration file is working. When happy then link it to Arduino.

    Make sure you have checked out the GCP videos on my website.

  • Thanks i watched them

  • edited March 2018

    I modified that and i now this line makes me problems: device = control.getMatchedDevice("leds"); i get this error:NumberFormatException:For input string:" 1" and also how i can check if a button on my controller is presed?

Sign In or Register to comment.