Why this Serial code not working?

Why this Serial code not working?

I have connected Tx of Transmitter to Rx of Receiver UNO R3.

Transmitter Code:

void setup() {
    Serial.begin(9600);
    delay(200);
}

void loop() {
    
    Serial.println("1");
    delay(2000);
    Serial.println("2");
    delay(2000);
}
[/code


Receiver Code:
[code]
String inputString = "";
boolean stringComplete = false;
int i = 0;

int Led = 12;

void setup() { 
  pinMode(Led, OUTPUT);  
  Serial.begin(9600);
  digitalWrite(Led, LOW);
}

void loop() {
    
  if(stringComplete) {
      if(inputString = "1")
      digitalWrite(Led, HIGH);
      else if(inputString = "2")
      digitalWrite(Led, LOW);
      
      inputString = "";
      stringComplete = false;
            
  }
    
}

void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read(); 
    // add it to the inputString:
    if (inChar == '\n') {
      stringComplete = true;
    } 
    else inputString += inChar;
    Serial.flush();
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:

  }
}

[/code]

= and == are not interchangeable.

Arrch:
= and == are not interchangeable.

Thank you for pointing out the silly mistake. Now it works with this code.

String inputString = "";
boolean stringComplete = false;
int i = 0;

int Led = 12;

void setup() { 
  pinMode(Led, OUTPUT);  
  Serial.begin(9600);
  digitalWrite(Led, LOW);
}

void loop() {
    
  if(stringComplete) {
      if(inputString == "1")
      digitalWrite(Led, HIGH);
      else if(inputString == "2")
      digitalWrite(Led, LOW);
      
      inputString = "";
      stringComplete = false;
            
  }
    
}

void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read(); 
    // add it to the inputString:
    if ((inChar == '\n') || (inChar == '\r')) {
      stringComplete = true;
    } 
    else inputString += inChar;
    Serial.flush();
    // if the incoming character is a newline, set a flag
    // so the main loop can do something about it:

  }
}

Now, it works with wired communication but not with 433 MHz RF modules. I also see a strange problem with transmitter board. If I burn sketch then I see Tx LED blinking every 2 sec but if I remove USB power and again power it then Tx LED doesn't blink and again I have to burn the sketch.

    Serial.flush();

Block until all pending output has been sent, in a sketch that never sends any serial data. Why?

I thought Serial.flush() will flush out the UART buffer (UDR).

I thought Serial.flush() will flush out the UART buffer (UDR).

It does. But which one? You are assuming that it flushes the incoming serial buffer. It does not. It blocks until the outgoing serial buffer is empty.

Pretty useless when you are not sending anything, don't you think?

Ok. I removed that line but still it is not working. If I connect using wire the LED blinks but it I use RF modules it doesn't work.

If I connect using wire the LED blinks but it I use RF modules it doesn't work.

Which RF modules? Cheap 433 MHz models need to use VirtualWire.