Here is the processing code i use. The 'teller' variable in the arduino code is used because the input is send twice. I use processing as the input for this script, left arrow down, right arrow up. I'll add videos of the problem as soon as they're uploaded.
Processing side of things
import processing.serial.*;
Serial myPort; // Create object from Serial class
String val; // Data received from the serial port
void setup()
{
size(200, 200); //make our canvas 200 x 200 pixels big
String portName = Serial.list()[2]; //change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial(this, portName, 9600);
}
void draw() {
if (keyPressed == true) {
if (key == CODED) {
if (keyCode == LEFT && keyPressed == true) {
keyPressed = false;
myPort.write('0');
println("links");
myPort.write('4');
} else if (keyCode == RIGHT) {
myPort.write('1');
println("rechts");
keyPressed = false;
myPort.write('4');
}
}
}
}
edit;
As soon as I move the dot up (left mouse button) it stops working
I can move down but when I move up it stops working.