Execute 1 time in multiple condition

Hi..Im having some problem to execute the operation under a condition with only 1 time with multiple condition... For example there is 3 condition If meet first condition it will print ("1") one time , if meet second condition it will print ("2") one time and same for third condition with ("3") one time...

The coding that I had tried

if ( A==LOW && B == LOW && C==LOW )
  {
    if ( temp == 0)
    {
    Serial.println("1")
    temp=1;
    }
  }

if (  A==LOW && B == LOW && C==HIGH )
  {
    if ( temp == 1)
    {
    Serial.println("2")
    temp=0;
    }
  }

if (  A==LOW && B == HIGH && C==HIGH )
  {
    if ( temp == 1)
    {
    Serial.println("3")
    temp=0;
    }
  }

But with those code It will only work for 2 changing the condition from 1st > 2nd or 1st > 3rd but it can't change from the 2nd > 3rd or 3rd to 2nd ....

Is there any solution to solve it?

What are A, B, and C in the real world? The values you are comparing them to suggest that they are the states of switches, and that you are looking at what the state of the switch IS every time through loop().

What you should be doing, I suspect, is looking at the state change detection example, to see when the state of A BECOMES pressed or BECOMES released, to see when the state of B BECOMES pressed or BECOMES released, and to see when the state of C BECOMES pressed or BECOMES released.

The code in the three bodies is not the same, with the exception of the value printed. Why not?

What are you REALLY trying to do?

PaulS:
What are A, B, and C in the real world? The values you are comparing them to suggest that they are the states of switches, and that you are looking at what the state of the switch IS every time through loop().

What you should be doing, I suspect, is looking at the state change detection example, to see when the state of A BECOMES pressed or BECOMES released, to see when the state of B BECOMES pressed or BECOMES released, and to see when the state of C BECOMES pressed or BECOMES released.

The code in the three bodies is not the same, with the exception of the value printed. Why not?

What are you REALLY trying to do?

The A B C is acaully a sensor... the sensor will connect to arduino with the digital pin as an input

Im trying to print the condition of the sensor to the serial one time when the condition is changing.

Im trying to print the condition of the sensor to the serial one time when the condition is changing.

So, the state is something on one pass through loop(). The state may have been the same last time, in which case no change occurred. The state may not have been the same last time, in which case a change did occur.

The state change detection example shows how to implement this.

PaulS:
So, the state is something on one pass through loop(). The state may have been the same last time, in which case no change occurred. The state may not have been the same last time, in which case a change did occur.

The state change detection example shows how to implement this.

Oh Thanks !! i had solved the problem !!