are you sure that the length of 'messageRecu' is exact and ONLY one character long? When transmitting, a 0 byte or a CR can also be added. When receiving, you simply convey everything that comes in in your 'while' loop into the char variable 'messageRecu'. but there are usually also 'end of transmission' characters. And so the comparison 'messageRecu == "1"' does not work because 'messageRecu' always consists of several characters. So you have to make sure when receiving that ONLY the actual command ends up in messageRecu.