NeoPixel wont work after Serial initialization

Hi fellow Devs,

my program is fairly simple, I initialize my NeoPixel light strip, show a white color on all pixels and connect myself to the Serial Port to receive further instructions.

The initial coloring works, in fact all light commands work until I initialize the Serial connection. The Serial monitor even shows non-ascii data until the Serial initialization.

Due to the intercept pattern used by the neopixel library it seems to be unable to send commands while a serial connection is established. Is there a way to pause the serial connection while the neopixel shows his colors?

I have found a similar error (Neopixel Show() interrupting serial communication) but I cant reproduce his answer. I do my serial listening before I send the color show() command, nevertheless the serial Monitor shows no color command nor does the light strips color change to red, as expected.

Could perhaps another serial library solve this issue?

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif

#define PIN            1
//0-255 (42 max due to 2A)
#define BRIGHTNESS     42

int numPixel = 192;
uint8_t colorOrder = 0x52;

String discoveryMessage = "Hi";
String discoveryAnswer = "Ola";
bool isConnected = false;
bool newData = false;

// Define new pointer for NeoPixel
Adafruit_NeoPixel *pixels;

/*
   Initial setup.
*/
void setup() {
  // This is for Trinket 5V 16MHz
#if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  InitLightStrip();
  // Shows a yellowish-white
  ColorLightStrip(255, 237, 150);  
  InitSerialPort();
}

/*
   Runtime Loop.
*/
void loop() {
  SerialListen();
  if (newData) {
    // TODO: Should show red, but does nothing..
    ColorLightStrip(255, 0, 0);
    newData = false;
  }
}

/*
   Initializes the light strip and turns all leds off.
*/
void InitLightStrip() {
  pixels = new Adafruit_NeoPixel(numPixel, PIN, colorOrder);
  pixels->begin();
  pixels->setBrightness(BRIGHTNESS);
  // Turns all to black
  pixels->show();
}

/*
   Initializes the serial port.
*/
void InitSerialPort() {
  // Start the hardware serial port
  Serial.begin(115200);
  // wait for serial port to connect. Needed for native USB port only
  while (!Serial) {
    ;
  }
}

/*
   Listens for incomming serial data until a new Line character appears.
*/
void SerialListen() {
  String incomingMessage = "";
  char c = 'a';
  while (c != '\n' && !newData) {
    while (!Serial.available() > 0) {
      delay(1);
    }
    c = char(Serial.read());
    if (c != '\n') {
      incomingMessage += c;
    } else {
      incomingMessage += '\0';
      newData = true;
    }
  }
  InterpretMessage(incomingMessage);
  Serial.flush();
}

/*
   Interprets the message by looking for a discovery message.
*/
void InterpretMessage(String message) {
  if (message.length() > 0) {
    if (message.substring(0, discoveryMessage.length()) == discoveryMessage) {
      Serial.println(discoveryAnswer);
      isConnected = true;
    } else {
      Serial.println(message);
    }
  }
}

/*
   Lights all leds on the strip to a given color.
*/
void ColorLightStrip(byte r, byte g, byte b) {
  for (int i = 0; i < numPixel; i++) {
    pixels->setPixelColor(i, pixels->Color(r, g, b));
  }
  pixels->show();
}
#define PIN            1
...
  pixels = new Adafruit_NeoPixel(numPixel, PIN, colorOrder);

Pin 1 is hard-wired to the board's USB-serial interface. If you're using it for Serial it won't work with the strip.

#define PIN            1
  pixels = new Adafruit_NeoPixel(numPixel, PIN, colorOrder);

Why are you using one of the Serial pins to drive the NeoPixels ?

Ohh, that explains the behavior! I did not know that pin 1 is used for the USB interface. I will solder it to another pin.

Thanks for the quick help.