Nano Every serial Event Failure

void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline, set a flag so the main loop can
// do something about it:
if (inChar == '\n') {
stringComplete = true;
}

digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second

The above event will not execute when serial data is sent from my computer. Thanks, Ron

Which pins are you using to connect the serial device to the Nano Every ?

I have deleted your duplicate topic

Not using pins. Using USB cable from PC to Nano Every.

The PC will receive text using a form created in Visual Studio 2019 Win Form App.

Works fine with MEGA 2560.

Personally I have never seen the use of the serialEvent() function. You may just as well do a Serial.available() when you need to know if serial data is available

It would be different if the serialEvent() function was an ISR triggered by the arrival of serial data, but it isn't

I am using Serial.available(), probably should not have called it Serial Event. Since the MEGA 2560 works I am going to try another Nano Every to see if the first was a unique situation.

probably should not have called it Serial Event

You were right to call it that and the function you posted is an example of such a function. If the function is present then it is called automatically at the end of loop()

What I was suggesting was not to create such a function and simply use Serial.available() to determine whether there was serial data to read

I am not familiar with the Nano Every but I believe that it has 2 serial interfaces and you may be reading the wrong one.

void setup()
Serial.begin(9600);
// reserve 200 bytes for the inputString:
inputString.reserve(200);
}

void loop() {

//delay(500);
while (Serial.available()) {
char inChar = (char)Serial.read();
inputString += inChar;
if (inChar == '\n') {
Serial.println(inputString);
}
}
}
I tried this with no success and with and without delay. I believe the Sketch tool shows the correct port number. Also the Nano Every would intermittently transmit bad data like 0/0/0/0 of various lengths. I believe there are serious timing problems.

Instead of using your Windows application, use the serial monitor. That might exclude your application as the problem.

Further, I think that the Nano Evey has native USB. In that case I suggest to modify setup.

void setup()
{
  Serial.begin(9600);
  pinMode(LED_BUILTIN, OUTPUT);
  while(!Serial)
  {
    digitalWrite(LED_BUILTIN, HIGH);
    delay(500);

    digitalWrite(LED_BUILTIN, LOW);
    delay(500);
  }
  // reserve 200 bytes for the inputString:
  inputString.reserve(200);
}

This will cause the Arduino to wait till an USB connection is established. It will flash the builtin led during the wait.

PS
your code in reply #9 will not compile; missing a { after setup().

Not using pins. Using USB cable from PC to Nano Every.
The program did compile, somehow the { was omitted when I posted. The Arduino Serial Monitor works fine but the project is based on communication with a PC.