I have a hard time making Arduino communicating with processing:
what should i write in the processing code to make it understand the arduino strings?
Is that not a Processing programming question whilst this is an Arduino programming forum ? But first you need to fix your Arduino code taking note of the recent posts.
Here is the start of a suggested way to program what you want to do
const byte inputPins[] = {2, 3};
const char outputChars[] = {'A', 'B'};
const byte NUMBER_OF_INPUTS = sizeof(inputPins) / sizeof(inputPins[0]);
void setup()
{
Serial.begin(115200);
for (int p = 0; p < NUMBER_OF_INPUTS; p++)
{
pinMode(inputPins[p], INPUT_PULLUP);
}
}
void loop()
{
for (int p = 0; p < NUMBER_OF_INPUTS; p++)
{
if (digitalRead(inputPins[p]) == LOW)
{
Serial.println(outputChars[p]);
}
}
}
NOTE : it needs changes to do exactly what you say you want
1 - detect when the input goes LOW rather than when it is LOW
2 - debounce the inputs if it causes problems
3 - maybe stop checking inputs once one is found LOW
4 - output a default character if none of the inputs are LOW but don't "spam" Processing by sending it continuously unless this is what you want