Communication between Raspberry pi and Arduino via GPIO

stowite:
The result of a digitalRead() call is either HIGH or LOW and not a numeric character as your code

if (PiState == 4 - '0') {

assumes .

So it should be
if (PiState == HIGH) {
digitalWrite(piPin1 , !digitalRead(piPin1));
}
else if{
digitalWrite(piPin2, !digitalRead(piPin2));
}