Arduino to Arduino transferred bytes can not be checked?

I am using 2 UNO's to make a serial connection between them. I want to send a "1" to the reciever arduino and check if its acutally "1" or not. I can easily send data and the recevier read it. But I cannot check the value. How can I check the value or is it even possible? Here are the codes:

The sender code is here:

char mystr[] = {'1', '2', '3', '4', '5', '6'};

void setup() {

  Serial.begin(9600);
}
void loop() {

      Serial.write(mystr[0]); //Write the serial data
}

Code is verified, so I do not think the problem is in here.

Here is the reciever code:

char mystr[10]; //Initialized variable to store recieved data
int alinan;
String okunan;
void setup() {

  // Begin the Serial at 9600 Baud
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);

}


void loop() {


  if (Serial.available()) {
    okunan = Serial.readString();
        Serial.println(okunan);


  }

  if (okunan.equals("1")) {
     digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
     delay(500);                       // wait for a second
     digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
     delay(500);                       // wait for a second


  }

And I can not check the read value by any means. I have tried checking it with if - else too. I have been struggling with this problem for a while now. Any solutions are greatly appreciated!

1. If you have connected your 2 UNOs in the following style (Fig-1), the communication might fail as the UNO has only one hardware UART Port which is permanently engaged with the IDE and Serial Monitor. Please, try to connect them using Sofware UART Port (SUART) as depicted in Fig-2 and then modify your program codes for both Transmitter and Receiver accordingly.

2. A Software UART Port (SUART) is created by including the following lines in the sketch:

#include<SoftwareSerial.h>
SofywareSerial mySUART(2, 3); // (SRX, STX)
mySUART.begin(9600);

3. All commands of UART Port are also applicable for the SUART Port except the void serialEvent(){} procedure which is reserved for hardware UART Port.

4.
uartUNO-1.png
Figure-1: UNO/UNO connection using hardware UART Ports.

5.
uartUnoUno-23.png
Figure-2: UNO/UNO connection using software UART Ports

6. Recommended Codes for the Receiver UNO-2 of Fig-2

#include<SoftwareSerial.h>
SoftwareSerial mySUART(2, 3);

//char mystr[10]; //Initialized variable to store recieved data
//int alinan;
//String okunan;
byte x;
void setup()
{
  // Begin the Serial at 9600 Baud
  Serial.begin(9600);
  mySUART.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop()
{
  if (mySUART.available())
  {
    x = mySUART.read();
    Serial.println((char)x);
  }

  if (x == '1')
  {
    digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(500);                       // wait for a second
    digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
    delay(500);                       // wait for a second
  }
}

uartUNO-1.png

uartUNO-2.png

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

The examples include a function to show what has been received.

The technique in the 3rd example will be the most reliable.

You can send data in a compatible format with code like this

Serial.print('<'); // start marker
Serial.print(value1);
Serial.print(','); // comma separator
Serial.print(value2);
Serial.println('>'); // end marker

...R

If you are sending a single byte in binary (that's what write() does), why on earth are you reading a String of ASCII data on the receiver?