Control led at pin 13 of Arduino 2 through serial communication from Arduino 1

hi,
i want to control LED at pin 13 of arduino 2 using Arduino 1 through Tx and Rx pins.
below is the code for sender and receiver arduino boards. these codes uses a push button to on , off led.
some one please rewrite code so I can control led without using pushbutton like a blink program.
remove the if else condition also
Receiver Arduino code


// Reciever Coder
int led = 13;
char inByte = '1';

void setup() {
 // put your setup code here, to run once:
 pinMode(led, OUTPUT);
 Serial.begin(9600);
}

void loop() {
 // put your main code here, to run repeatedly:
 if (Serial.available())
 {
   inByte = Serial.read();
   if (inByte == '1')
   {
     digitalWrite(led, 1);
   }
   else
   {
     digitalWrite(led, 0);
   }
 }

}


Transmitter Arduino Code

// Transmitter Coder
int button = 13;
char inByte = '1';

void setup() {
  // put your setup code here, to run once:
  pinMode(button, INPUT_PULLUP);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  if (digitalRead(button) == 0)
  {
    Serial.write(inByte);
    delay(100);
  }
  else
  {
    Serial.write('0');
    delay(100);
  }
}


Do you use the button? I don’t see any code for it other than declaring it

If you want blink then upload this and change the digitalwrite ledPin code to your serial code

There is information on using serial here:

your receive code works for me. i'm simply entering a '1' or '0' thru the serial monitor and have set the serial monitor for "no line ending"

but realize that any other char, including a newline, \n, or \r is the else case.

also realize that the serial pins, 1&2 are used to communicate with the PC to download code as well as the serial monitor if you tried connecting 2 UNOs together

i want to control LED at pin 13 of receiver arduino with push button just like simple led blinking

why don't you try and we can help if you get stuck.

Previously you said you want to control without the push button! Which one is it?

There are many tutorials on buttons for arduino so it won’t take you too long if you want this functionality. It is the same code in that your arduino does not care what condition you use to run your serial code push button, time etc.

Write your code for what you want to do and then tell us where it fails to achieve your requirements