My SoftewareSerial port is "not declared in this scope" compile error

My hardware is an Arduino Uno rev 3. I am using a 2X16 LCD to display timers from my program. Everything works fine printing to the Serial port but I need the standalone functionality of the LCD. I can't seem to get the SoftwareSerial declaration of myPort properly created. I simply don't see my error. This sketch only prints to the Parallax 2X16 Serial LCD. Until I have the display properly formatted, I'm just running a black box. Thanks for the help!

void setup() {
  // put your setup code here, to run once:
  // Using the myPort output lets you view
  //  program fuction via the myPort monitor when enabled
  
#include <SoftwareSerial.h>
SoftwareSerial myPort(10,11); // RX, TX
myPort.begin(2400);

pinMode(6, OUTPUT);

}

void loop() {
  // put your main code here, to run repeatedly:
  
 for(int Mins = 0; Mins <20 ; Mins++){ 
 for(int Secs = 0; Secs < 60; Secs++){
  delay (1000);
  myPort.println("Run");
  myPort.print(Mins);
  myPort.print(" Mins ");
  myPort.print(Secs);
  myPort.println(" Secs");

You've left out the 'setup()' function and a few braces. This compiles:-

#include <SoftwareSerial.h>
SoftwareSerial myPort(10, 11); // RX, TX

void setup()
{
    pinMode(6, OUTPUT);
    myPort.begin(2400);
}

void loop()
{
    // put your main code here, to run repeatedly:

    for (int Mins = 0; Mins < 20 ; Mins++)
    {
        for (int Secs = 0; Secs < 60; Secs++)
        {
            delay (1000);
            myPort.println("Run");
            myPort.print(Mins);
            myPort.print(" Mins ");
            myPort.print(Secs);
            myPort.println(" Secs");
        }
    }
}

I'm not familiar with that serial LCD module, so I'll assume that you know what you're doing in that regard.
(I'm more familiar with parallel or I2C LCD displays.)
You might need to clear the screen between cycles of 'loop()' though, and I assume this all prints to the first line of the LCD, since you never select the second line.

I don't know what pin 6 is supposed to do. You set it as an output, but never use it.

You did not post the entire code, but

#include <SoftwareSerial.h>
SoftwareSerial myPort(10,11); // RX, TX

Should go before void setup.

Excellent, thanks I never really did well with scissors in preschool, it just makes sense I'd bugger the cut and paste on my code. Second attempt.

void setup() {
  // put your setup code here, to run once:
  // Using the myPort output lets you view
  //  program fuction via the myPort monitor when enabled
  
#include <SoftwareSerial.h>
SoftwareSerial myPort(10,11); // RX, TX
myPort.begin(2400);

pinMode(6, OUTPUT);

}

void loop() {
 
  
 for(int Mins = 0; Mins <20 ; Mins++){ 
 for(int Secs = 0; Secs < 60; Secs++){
  delay (1000);
  myPort.println("Run");
  myPort.print(Mins);
  myPort.print(" Mins ");
  myPort.print(Secs);
  myPort.println(" Secs"); 
  
  } 
 }
}

fatmanonabike:
Excellent, thanks I never really did well with scissors in preschool, it just makes sense I'd bugger the cut and paste on my code. Second attempt.

Go back and look at the corrected code that I posted in reply #1.

Edit: And it's a good idea to hit Ctrl-T or ">Tools >Auto Format" in the IDE before posting. It will format your code with the correct indentations. It also highlights any braces that you might have left out.

Thanks nathancamp! Bonus points for reading user's mind in that I did not post the entirety of my code.

Thanks OldSteve. I guess I should learn the IDE before trying to produce a sketch. I learn something every time I log on but they've blocked the Arduino site at work.

fatmanonabike:
...but they've blocked the Arduino site at work.

So would I if I was the boss. :smiley:

And a tip. After you've received comments/replies on your posted code, never go back and edit it. That just makes the replies look stupid.
I mentioned that you had no 'setup()' function, and now miraculously one has appeared, making that part of my reply meaningless.

OldSteve point taken. Right. You really saved me hours of wailing and gnashing of teeth. I am both appreciative and humbled. May i learn enough to one day pay it forward.
Thanks again.

fatmanonabike:
OldSteve point taken. Right. You really saved me hours of wailing and gnashing of teeth. I am both appreciative and humbled. May i learn enough to one day pay it forward.
Thanks again.

No problem. Glad to help.