Software Serial Library

Hi all,

I'm new to Arduino. Recently, I was playing around with serial communication between 2 Arduino Uno. Basically, I have 2 arduino Unos, each rigged with a multicolor LED and initially setup to flash a different color. The idea is that if the 2 arduino boards are connected through the pins designated by the software serial port, their colors would sync. The strange thing is that the code seems to work prefectly fine when I attached (powered) the 2 boards via USB cable, but when I switch both (or either) over to v9 batteries, they do not seem to communicate any more (Each arduino just flashes their own color). Anybody got an idea why this is so? Thanks!

Here's the code snippet:

SoftwareSerial neighbor(2,3); 
int my_color = 0;

void setup() {
  my_color = 0;    // uploaded to arduino board 1
  // my_color = 5; // uploaded to arduino board 2
  // Serial.begin(9600);

void loop() {
  if (neighbor.available()) {
      int received_color =;
      int new_color = (my_color + received_color) / 2;
      // Serial.print("Received color suggestion: ");
      // Serial.print(received_color);
      // Serial.print("\n");
  } else {
      // Serial.print("No suggest from neighbor, using my own color: ");
      // Serial.print(my_color);
      // Serial.print("\n");

void set_color(int color_value) {
   // Uninteresting bits... just tell LED to change color

Have you got the grounds of the two boards connected?

Hello Lemming,

Thanks for your reply! Oh my... the answer is no. Could you elaborate how I can do that and why it might be the cause of the problem? Sorry if those sound like lame questions, but I'm really new at this.. =P

Just connect the GND of one to the GND of the other.

Without a reference point (ie the GND) the voltage levels seen by each Arduino can be any old crap, probably similar to the pins just floating.

When you were using USB the GNDs where connected via the USB cables. With the batteries there is no connection.


Thanks Graynomad and Lemming!

I realise that this problem I face is not really a programming question after all. My apologies to all, for misplacing the question in this topic.. =P

That’ s OK, often a problem manifest itself in a different area, or at least seems to.