Project about transmitting messages between two arduino and to light up the right leds in both arduino

Hi, I'm doing a school project about the communication between two arduino uno, and I'm kinda stucked, I don't really understand what I'm doing wrong and even asking around(Discord etc.) isn't working.
The goal of the project is to be able to transmit messages (the letters, in my case, s, u and p in ascii) to the other arduino, and to light up, in bot arduinos, the espective leds(the red one for the s, orange one for the u, the yellow one for the p and the last one is an "error", the green led should not be in the first arduino, since the goal of the error is to press the button and make the led light up only in the second arduino, but I needed it to test it), but it doesn't work ..
We're yet to study the serial and i'm really having a lot of trouble with this project
Since I'm italian I tried to translate the comments, I'm really sorry if the translation and my english are bad


This is the trasmitter code:

//led statement
int ledRosso=12;
int ledArancio=11;
int ledGiallo=10;
int ledErrore=9;

//statement buttons with the respective colors of the LEDs
int botRosso=8;
int botArancio=7;
int botGiallo=6;
int botErrore=5;

//transmitter declaration
int TX=4;

//bit time declaration
int tbit=1;

//counter declaration for the for loop
int i=0;

//declaration of the frame to be transmitted (= SUP)
//frame: start bit, 8 bit (letter in ascii), parity bit, stop bit
//start / stop bit = 1
//parity coding = even

//plot of the letter 'S' in ascii = 01010011
int S[11]= {1,0,1,0,1,0,0,1,1,0,1};
//plot of letter 'U' in ascii = 01010101
int U[11]= {1,0,1,0,1,0,1,0,1,0,1};
//plot of the letter 'P' in ascii = 01010000
int P[11]= {1,0,1,0,1,0,0,0,0,0,1};
//plot of letter 'U' with ascii error = 01111101
int Ue[11]= {1,0,1,1,1,1,1,0,1,0,1};

void setup()
{
  //led setup
  pinMode(ledRosso, OUTPUT);
  pinMode(ledArancio, OUTPUT);
  pinMode(ledGiallo, OUTPUT);
  pinMode(ledErrore, OUTPUT);
  
  //button setup with internal resistance
  pinMode(botRosso, INPUT_PULLUP);
  pinMode(botArancio, INPUT_PULLUP);
  pinMode(botGiallo, INPUT_PULLUP);
  pinMode(botErrore, INPUT_PULLUP);
  
  //transmission setup
  pinMode(TX, OUTPUT);
}

void loop()
{
  //control of the red button to switch on the respective LED
  if(digitalRead(botRosso)==LOW){
    //switching on of the red led
    digitalWrite(ledRosso, HIGH);
    //transmission of the plot of the letter S in ascii = 10101001101
	//start bit, ascii letter, parity bit and stop bit
    for(i=0; i<11; i++){
      digitalWrite(TX, S[i]);
      delay(tbit);
    }
  }
  //control of the orange button to switch on the respective LED
  else if(digitalRead(botArancio)==LOW){
    //the orange led lights up
    digitalWrite(ledArancio, HIGH);
    //transmission of the plot of the letter U in ascii = 10101010101
	//start bit, ascii letter, parity bit and stop bit
    for(i=0; i<11; i++){
      digitalWrite(TX, U[i]);
      delay(tbit);
    }
  }
  //control of the yellow button to switch on the respective LED
  else if(digitalRead(botGiallo)==LOW){
    //switching on of the yellow led
    digitalWrite(ledGiallo, HIGH);
    //transmission of the plot of the letter P in ascii = 10101000001
	//start bit, ascii letter, parity bit and stop bit
    for(i=0; i<11; i++){
      digitalWrite(TX, P[i]);
      delay(tbit);
    }
  }
  //control of the green button to switch on the respective LED
  else if(digitalRead(botErrore)==LOW){
    //green led lights up
    digitalWrite(ledErrore, HIGH);
    //plot transmission of letter U in modified ascii = 10111110101
	//start bit, ascii letter, parity bit and stop bit
    for(i=0; i<11; i++){
      digitalWrite(TX, Ue[i]);
      delay(tbit);
    }
  }
  else{
    digitalWrite(ledRosso, LOW);
    digitalWrite(ledArancio, LOW);
    digitalWrite(ledGiallo, LOW);
    digitalWrite(ledErrore, LOW);
    digitalWrite(TX, LOW);
  }
  digitalWrite(TX, LOW);
  delay(15*tbit);
}

This is the reciver code:

//led statement
int ledRosso=7;
int ledArancio=6;
int ledGiallo=5;
int ledErrore=4;

//declaration reception
int RX=10;

//bit time declaration
int tbit=1;
//declaration of half the bit time
float mtbit=tbit/2;

//declaration with the for loop with which it will read the incoming message
int i=0;

//declaration of the supporting variable reading the message arriving from the transmission
int messaggio[10];

void setup()
{
  //led setup
  pinMode(ledRosso, OUTPUT);
  pinMode(ledArancio, OUTPUT);
  pinMode(ledGiallo, OUTPUT);
  pinMode(ledErrore, OUTPUT);
  
  //reciver setup
  pinMode(RX, INPUT);
}

void loop()
{
  while(digitalRead(RX)==HIGH){};
  delayMicroseconds(mtbit);
  if(digitalRead(RX)==HIGH){
    for(i=0; i<10; i++){
      messaggio[i]=digitalRead(RX);
      delay(tbit);
    }
//check of the message received to switch on the red LED   if(messaggio[0]==1&&messaggio[1]==0&&messaggio[2]==1&&messaggio[3]==0&&messaggio[4]==1&&messaggio[5]==0&&messaggio[6]==0&&messaggio[7]==1&&messaggio[8]==1&&messaggio[9]==0&&messaggio[10]==1){
      digitalWrite(ledRosso, HIGH);
    }
  }
}

In the reciver I just tried to light up a led(the red one) but it doesn't work
I'm really sorry for copying the code here but .txt aren't fine
I thank in advance who will help me, this is the first time I write in a forum for help so sorry if I made a mistake in selecting the section or something else

Do you understand the theory about how the bit serial transmission should work?

I suggest that you get rid of all the buttons and leds, and just work on making the bit serial transmission work. It looks like the basics are there, but this is a fatal mistake:

//bit time declaration
int tbit=1;
//declaration of half the bit time
float mtbit=tbit/2;

Since tbit is an integer, set equal to 1, tbit/2 is zero by integer division, which is the default for the right hand side of the expression. It does not matter that "mtbit" is declared float.

Continuing, delay() expects integer arguments, so it can't be used with fractional float values. To delay by 0.5 milliseconds, most people would use delayMicroseconds(500).

Not to detract from your effort, but the industry standard for ASCII data transmission is always to send the low order bit first, the high order bit last.
But where you are making up the rules for both transmit and receive, you can do it either way.
Good luck,
Paul

thank you very much for explaining this error to me, I didn't know floats worked like this in arduino, since it's the first year I've been doing arduino and I'm used to coding with c / c ++, that's why I used the float in that way
I changed the bit time and directly eliminated half, replacing in microseconds with 500 instead of mtbit
thank you so much for the help

I am aware of it, I simply did it for convenience, when it is concluded I will reverse the sense of the bits and I will declare it in the comments, thanks a lot anyway.

In Tx you have:
int S[11]= {1,0,1,0,1,0,0,1,1,0,1};

. . .

In RX you have:
for(i=0; i<10; i++)

is there any reason why you don't want to use SoftSerial and just send - and receive - with a default library made for transmitting data?

Send

mySerial.print("A");

Receive

    if (Serial.available() > 0) {
        char c = Serial.read();
        // do something with  c
    }