int a = digitalRead(2);
Serial.println(a); //send value to serial
Sends the HIGH or LOW value as a string.
if ( myPort.available() > 0) { // If data is available,
val = myPort.read(); // read it and store it in val
}
background(255); // Set background to white
if (val == 0) { // If the serial value is 0,
fill(0); // set fill to black
}
else { // If the serial value is not 0,
fill(204); // set fill to light gray
}
Expects a binary input, which was NOT what was received. Try
if(val == '0')