Photon serial menu

my photon doesn’t print from the “setup” loop im trying to display a few options from my main loop while it reads the serial port. basically a "serial menu"
if plug it in then rapidly open serial monitor on the arduino IDE or even putty i get the setup function to show and the main loop running, but is there a way to make setup show once plugged or flashed every time?
a very basic snippet

void setup()
{
   Serial.begin(9600);
   Serial.println ("startup string to test");
   while(!Serial);
}

void loop()
{
    Serial.println("Hello world!");
    delay(1000);
}

This line doesn’t do what you want. Serial is a class, and is never false so it never loops.

while(!Serial);

What you want instead is something like this: It will wait until a serial terminal program is connected, or 30 seconds, whichever is first, before exiting setup().

waitFor(Serial.isConnected, 30000);
2 Likes

Thanks going to try this out.

it works thanks! never knew about this function lol got some reading to do.