I'm in arduino cloud and when i open up serial ports it says that my serial ports are unavailable
Serial.available()
returns the # of chars available to read, not that the Serial port is ready to use
in the following, a read is attempted only after some chars are ready to be read. the serial monitor should be set to terminate with a newLine
void
loop (void)
{
if (Serial.available ()) {
char buf [90];
int n = Serial.readBytesUntil ('\n', buf, sizeof(buf)-1);
buf [n] = '\0';
Serial.println (buf);
}
}
void
setup (void)
{
Serial.begin (9600);
}
thank you for your code it worked very well.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.