Serial working from FTDI but not from second arduino

Hi,

I’m having a little trouble with some code on an Arduino pro mini which works fine when I feed it serial commands using my FTDI cable however this is just for testing. I really want to send the commands from a controller made from an arduino uno. The problem is when I to send commands using the second arduino it doesn’t work. I viewed the data coming from the second arduino and it appears to be identical to what I sent via the FTDI cable.

My code is pretty long but so I’ll just include what I think are the important snippets.

My code on the pro mini is:

void serialEvent() {
  while (Serial.available() > 0) {
    char recieved = Serial.read();  // Receive byte
            
        receive_id += recieved;     // Add to id string
   
  if (receive_id == "F936"){        // Check if id is correct
    Serial.print("id");
    while(command_val == 0x00){     // Wait for the command
      if (Serial.available()) {
        command_val=Serial.read();
        
        if (command_val == '\n')    // Clear id strin when 0A received
        {
          Serial.print("gotn");
            receive_id = "";        // Clear id strin
            command_val = 0x00;     // Clear command
        }
      }
    }
    if(command_val<0x05){           // If command <05 wait for associated data
      Serial.print("com");
      while(data_val == 0x00){
        if (Serial.available()) {
          Serial.print("dat");
          data_val=Serial.read();
        }
      }
    }
  }

  else if (recieved == '\n'){      // If 0A received then wrong id
              receive_id = "";     // Clear id string
  }
  }
}

And the controller code is:

y1_val = analogRead(A4);
  delay(5);
  left_speed = map(y1_val, 0, 1024, 0x00, 0xFF);     
  //left_speed=0xFF-left_speed;
  delay(2000);
  Serial.write(0x46);  // F
    delay(2000);
  Serial.write(0x39);  // 9
    delay(2000);
  Serial.write(0x33);  // 3
    delay(2000);
  Serial.write(0x36);  // 6
  delay(2000);
  Serial.write(0x0A);  // \n
  delay(2000);
  Serial.write(0x01);  // Command to enter drive mode
  delay(2000);
  Serial.write(left_speed);  // Drive value
 delay(2000);

  y2_val = analogRead(A1);
  delay(5);
  right_speed = map(y2_val, 0, 1024, 0x00, 0xFF); 
  //right_speed = 0xFF-right_speed;
delay(2000);
Serial.print("F936");  // F936
delay(2000);
Serial.write(0x0A);  // \n
delay(2000);
Serial.write(0x02);  // Command to enter steering mode
  delay(2000);
  Serial.write(right_speed);  // Steering value
  delay(2000);

Is there something obvious I’m doing wrong here?

You have Rx to Tx, Tx to Rx, and Gnd to Gnd?

Yes and to be sure I connected the FTDI cable to the rx of the pro mini and I could see the data coming from the uno tx

How does this value get set before it gets to this line?

while(command_val == 0x00){ // Wait for the command

Maybe the logic is good, and I'm just seeing it funny.

At the start of the code I have

byte command_val = 0x00;

Once a command value greater than 0x00 is received, it carries out the command and then is once again returned to 0x00 with the following line

command_val = 0x00;

I think I may have some dinner, let the battery recharge and check my wiring again. Maybe I'll spot something after I've taken a break :)

Sounds like a good plan, it has worked for me in the past.