You should find a better translator. Try google translate. Many of us are not native English speakers so your poor English is really not helping us understand what you want.
I guessed what you want is to capture X and then A from serial port and do something when this happens.
You have a loop, the loop() function to loop around while you check for X. That works. You need another loop to check for A:
void loop()
{
char in_byte=0;
while (!serial.available()) //Wait for incoming character
{}
in_byte=Serial.read();
if (in_byte=='X')
{
while (!serial.available()) //Wait for incoming character
{}
in_byte=Serial.read();
if (in_byte=='A')
{//Do your X then A action
}
}
}
I think I know what you want but just to be sure.
If X is pressed then you want to check if the A or B is then pressed.
OR
do you want to read in multiple characters at one time, A string of characters?
XA or XB
reading in a string of characters is easy, but if you want to read X in first then check if either A or B comes in next, then that might be a little tougher to do.
void setup()
{
Serial.begin(9600);
Serial.println("POWER ON");
}
void loop()
{
char in_byte=' ';
while (!Serial.available()) //Wait for incoming character
{}
in_byte=Serial.read();
if (in_byte=='X')
{
Serial.println("X");
while (!Serial.available()) //Wait for incoming character
{}
in_byte=Serial.read();
if (in_byte=='A')
{//Do your X then A action
Serial.println("A");
}
}
}
still cannot, after i key in 'X' its shown the serial.print"X", but then, i key in 'A', nothing happen....
Oh and one more thing, after you get a char in, you should clear it. It is not really necessary in your case, but it won't hurt it.
if (in_byte=='X')
{
in_byte=' '; // clears for new char
while (!serial.available()) //Wait for incoming character
{}
in_byte=Serial.read();
if (in_byte=='A')
{
in_byte=' ';
//Do your X then A action
}
}
Make sure you have the right option as indicated in the red box.
I don't think clearing the in_byte has any effect to the program flow. Probably OP made the change of the option in the monitor dialog box so it now is sending characters without end of line characters.