You send messages via the serial port. If you have TX of one Arduino connected to RX of the other, and vice versa, with grounds connected, then:
void loop()
{ // Down here where it belongs
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH)
{
Serial.print('1');
}
else
{
Serial.print('0');
}
Then
int Rx = Serial.read() - '0';
if (Rx == 1)
{
Serial.println("Led is on");
digitalWrite(LedPin,HIGH);
}
else if (Rx == 0)
{
Serial.println("Led is off");
digitalWrite(LedPin,LOW);
}
else
{
Serial.println("Invalid!");
}
But no Serial.flush(). Throwing away random amounts of unread data, or blocking until one character is sent, depending on the version of the IDE you are using, makes no sense.