Hi,
I'm trying to use serialEvent with a Nano Every board. Does it work ?
Prior, my code is running perfectly with a Nano. I need more memory, so I've decided to upgrade to Nano Every. Same code, just a compile and upload.
Then it does not work anymore.
Any feedback on serialEvent and Nano Every board ?
Thanks in advance,
#include <Adafruit_NeoPixel.h>
#define led_pin 2
String inputSerialString = "";
bool serialStringComplete = false;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(134, led_pin, NEO_GRB + NEO_KHZ800);
void setup() {
// Initialize the led strip
strip.begin();
strip.setBrightness(20);
strip.show(); // All pixels to 'off'
Serial.begin(9600);
inputSerialString.reserve(200);
}
void loop() {
// Process the command when a new one arrives
if (serialStringComplete) {
// Process the new command
displayMyStuff(inputSerialString);
// Clear the buffer
inputSerialString = "";
serialStringComplete = false;
}
}
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputSerialString += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == '>') {
serialStringComplete = true;
}
}
}
void displayMyStuff(String s) {
strip.setPixelColor(0, strip.Color(255, 0, 0));
strip.show();
}