I am currently creating an app, where my Android phone continuously sends a Color-Integer to my Arduino. After that, the single RGB-Channels are parsed and sent to the Neopixel. I get a horrible flickering effect. Thus, I get some "?" in my Serial Monitor. Without the Neopixel connected, everything just seems to work fine (regarding the receiving and parsing of the Color). Is there any way to fix that Bluetooth-Neopixel-Problem?
My Code on Arduino-Site is the following:
void loop() {
if (bluetooth.available()){
current = bluetooth.read();
if(current == endChar) {
if(msg[0] = 'C') { // The first Character is the "key" to be received on Arduino
colorChange(msg);
} else if(msg[0] == 'S') {
fadeMode = true;
}
msg = "";
} else {
msg+=current;
}
}
}
void colorChange(String msg) {
//fadeMode = false;
msg.remove(0,1);
currentColor = atol(msg.c_str());
red = (currentColor >> 16) & 0xFF;
green = (currentColor >> 8) & 0xFF;
blue = currentColor & 0xFF;
for(int i = 0; i < NUMPIXELS; i++) {
pixels.setPixelColor(i, pixels.Color(red, green, blue));
}
pixels.show();
}