Processing is receiving strings. If '!' is sent, that will be received as 33 (decimal). If Processing is supposed to do something when 33 is received, how do you plan to distinguish that from when A0 reads 33 and that is sent? By the same token, if '?' (63), is sent is that A1 data or a signal that A1 read 0?
I would build one packet of data with the required data inside in a form that Processing can parse then send with one write. In this case maybe a byte (bool) that says if one of the buttons were pressed, an int that holds the reading from A0 and an int that holds the data from A1. Let Processing decide what to do with the A0 reading if the buttons are pressed. Same as Processing can determine if the A1 data is 0 so there is no need to send a special character for that.
So something like this. The first data will be the button state then a comma then the A0 reading a comma and the A1 reading. Read in the String and use the split function to separate the 3 data parts then process them further.
bool buttonPressed = 0; // true if either button1 or button2 pressed
int A0Value = 0;
int A1Value = 0;
void setup()
{
Serial.begin(115200);
}
void loop()
{
static unsigned long timer = 0;
unsigned long interval = 1000;
if (millis() - timer >= interval)
{
timer = millis();
buttonPressed = 0;
if ((digitalRead(10) == 1) || (digitalRead(11) == 1))
{
buttonPressed = 1;
}
A0Value = analogRead(A0);
A1Value = analogRead(A1);
char buffer[12]; // to hold the packet
snprintf(buffer, sizeof(buffer), "%d,%d,%d", buttonPressed, A0Value, A1Value);
Serial.println(buffer);
}
}