Serial monitor failing to update after serial communication

I've created two programs although one of them isn't exact one I am gonna use once I am done but it was just something I was gonna use to test.

I have Arduino Uno that I want to receive data from an Arduino Nano.

Nano Code in void loop():

void mode1() {  // Glove Control Mode

  // Transmitter Code
  value1 = analogRead(flexPin1);
  value2 = analogRead(flexPin2);
  value3 = analogRead(flexPin3);
  value4 = analogRead(flexPin4);
  value5 = analogRead(flexPin5);

  flex1 = map(value1, 762, 861, 0, 180); // PINKY **
  flex1 = constrain(flex1, 0, 180); 

  flex2 = map(value2, 754, 836, 0, 180); // RING **
  flex2 = constrain(flex2, 0, 180);

  flex3 = map(value3, 806, 895, 0, 180); // THUMB ** *
  flex3 = constrain(flex3, 0, 180);

  flex4 = map(value4, 784, 876, 0, 180); // MIDDLE **
  flex4 = constrain(flex4, 0, 180);  

  flex5 = map(value5, 778, 875, 0, 180); // POINTER **
  flex5 = constrain(flex5, 0, 180);  

  transmit[0] = flex1;
  transmit[1] = flex2;
  transmit[2] = flex3;
  transmit[3] = flex4;
  transmit[4] = flex5;

  Serial.write((byte*)transmit,sizeof(transmit)); //get values to read on screen
  

  //get mode to read on screen.

  Serial.println("PINKY: " + String(transmit[0]));
  Serial.println("RING: " + String(transmit[1]));
  Serial.println("MIDDLE: " + String(transmit[2]));
  Serial.println("INDEX: " + String(transmit[3]));
  Serial.println("THUMB: " + String(transmit[4]));

  // Serial.println(flex1);
  // Serial.println(flex2);
  // Serial.println(flex3);
  // Serial.println(flex4);
  // Serial.println(flex5);

  delay(10);
}

Uno Code:

int receivedData[5];  //flex sensor values

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

void loop() {
  static byte receivedIndex = 0;
  static byte* receivedPtr = (byte*)receivedData;

  if (Serial.available()) {
    *receivedPtr = Serial.read();
    receivedPtr++;
    receivedIndex++;

    if (receivedIndex == sizeof(receivedData)) {
      // All data received, print the values
      for (int i = 0; i < 5; i++) {
        Serial.print("Finger ");
        Serial.print(i);
        Serial.print(": ");
        Serial.println(receivedData[i]);
      }

      // Reset for the next data set
      receivedIndex = 0;
      receivedPtr = (byte*)receivedData;
    }
  }

  // Rest of your code here
}

As individual programs they work great, although I can't really test the other without the Nano sending but the problem is as soon as I connect the tx/rx and ground pins so that they can communicate neither serial monitors will update and it seems as if the program completely freezes. Why is this?

I've sent a photo of the Nano circuit if that helps finding out the issue although I do not use the same ground where the capacitor goes through.

(The uno is just by itself)

Your project inter-arduino comms use Serial, so does Serial Monitor. Detect a conflict?

What do you mean by conflict exactly?

Your project's use of serial is still not clear to me, but I'll just step out. Good luck!

This a very base of what I want but I am just testing to see if I can actually received the values being sent which I am not.

Arduino UNO and Arduino Nano both have only one serial UART interface. Because the UART interface is not a bus, you cannot use it to communicate to another Arduino AND to the serial Monitor in the same sketch.

1 Like

One transmitter can send to multiple receivers at once, but you can't just short multiple transmitters together.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.