Problem with serial communication

Let's try this then:

boolean sendSerial(long data, long waitTime) {
  byte Iattempts = attempts;
  Serial.begin(9600);
  Serial.print(data);
  unsigned long startTime;
  while (Serial.read() != "*") {
    if (millis() - startTime =< waitTime) {
      return 0;
    }
  }
  Serial.print("+");
  while (Serial.read() != "^") {
    startTime = millis();
    if (millis() - startTime =< waitTime) {
      return 0;
    }
  }
  delay(5);
  return 1;
}



char receiveSerial(long waitTime2) {
  Serial.begin(9600);
  long returnData = Serial.read();
  Serial.print("*");
  while (Serial.read() != "+") {
    unsigned long startTime2 = millis();
    if (millis - startTime = waitTime2) {
       return 0;
    }
  }
  Serial.print("^");
  return returnData;
}

The function sendSerial() sends data and waits for a comfirmination. If the timeout goes to 0, sendSerial() returns 0, indicating that there was no comfirmination.

The function receiveSerial() returns what data was transmitted, and it also waits for a confirmination. If the timeout goes to 0, receiveSerial() returns 0, indicating no data or a timeout.

It is also possible to communicate between Arduino boards with I2C or SPI.