Button connection from Arduino to Processing

Hello @friedadedoncker,

The A/D on an Arduino is 10-bit and returns a 16-bit integer from 0 to 1024.

I modified the code from here to provide more flexibility:

How to Send Multiple Signals from the Arduino to Processing - dummies

Arduino Code
// https://www.dummies.com/article/technology/computers/hardware/arduino/how-to-send-multiple-signals-from-the-arduino-to-processing-164740/

/*
 Serial Call and Response
 Language: Wiring/Arduino
 This program sends an ASCII A (byte of value 65) on startup
 and repeats that until it gets some data in.
 Then it waits for a byte in the serial port, and
 sends three sensor values whenever it gets a byte in.
 Thanks to Greg Shakar and Scott Fitzgerald for the improvements
 The circuit:
 * potentiometers attached to analog inputs 0 and 1
 * pushbutton attached to digital I/O 2
 Created 26 Sept. 2005
 by Tom Igoe
 modified 24 April 2012
 by Tom Igoe and Scott Fitzgerald
 This example code is in the public domain.
 http://www.arduino.cc/en/Tutorial/SerialCallResponse
 */

int inByte = 0;   // incoming serial byte

void setup()
  {
  // start serial port at 9600 bps:
  Serial.begin(9600);
//  while (!Serial) 
//    {
//    ; // wait for serial port to connect. Needed for Leonardo only
//    }
  establishContact(); // send a byte to establish contact until receiver
      // responds
  delay(1000);
  }

int count;

void loop()
  {
 // if we get a valid byte, read analog ins:
  if (Serial.available() > 0) 
    {
    // get incoming byte:
    inByte = Serial.read();

    delay(100);
    Serial.print(count);
    Serial.print(',');
    Serial.print(random(-100, 100));
    Serial.print(',');
    Serial.print(random(-100, 100));
    Serial.print('\n');

    count++;
    if (count>360) count = 0;
    }
  }
  
void establishContact() 
  {
  while (Serial.available() <= 0) 
    {
    Serial.print('A'); // send a capital A
    Serial.print('\n');
    delay(300);
    }
  }
Processing Code
// This example code is in the public domain.
import processing.serial.*;
int bgcolor;   // Background color
int fgcolor;   // Fill color
Serial myPort;      // The serial port
//int[] serialInArray; // Where we'll put what we receive
int serialCount = 0;     // A count of how many bytes we receive
int xpos, ypos;     // Starting position of the ball
boolean firstContact = false;  // Whether we've heard from the
// microcontroller

int count;
int x, y, hue;

void setup()
  {
  size(250, 250, P3D); // Stage size
  colorMode(HSB, 360, 100, 100);
  background(128);
  
  //noStroke();  // No border on the next thing drawn
  // Set the starting position of the ball (middle of the stage)
  xpos = width/2;
  ypos = height/2;
  // Print a list of the serial ports, for debugging purposes:

  printArray(Serial.list());

  // I know that the first port in the serial list on my mac
  // is always my FTDI adaptor, so I open Serial.list()[0].
  // On Windows machines, this generally opens COM1.
  // Open whatever port is the one you're using.
  String portName = Serial.list()[4];
  myPort = new Serial(this, portName, 9600);
  delay(10);
  myPort.clear();
  myPort.bufferUntil('\n');
  noLoop();
  }

void draw()
  {
  if (hue == 0)  
    background(128);
  translate(width/2, height/2);
  rotateY((frameCount%360)*TAU/360);
  strokeWeight(5);
  stroke(hue, 100, 100);
  point(x, y);
  }

void serialEvent(Serial myPort)
  {
  println(count++);
  // read a byte from the serial port:
  String inString = myPort.readStringUntil('\n');
  inString = trim(inString);
  println(inString, inString.length());

  if (firstContact == false)
    {
    if (inString.equals("A") == true)
      {
      println('!');
      myPort.clear();   // clear the serial port buffer
      firstContact = true;  // you've had first contact from the microcontroller
      myPort.write('A');  // ask for more
      }
    } 
  else
    {
    int[] serialInArray; // Where we'll put what we receive
    serialInArray = int(split(inString, ','));
    hue = serialInArray[0];
    x = serialInArray[1];
    y = serialInArray[2];
    printArray(serialInArray);
    myPort.write('A');  // ask for more
    redraw();
    }
  }

References:

:)