Tiny GPS+ and maidehead locators

So I’m having a play with GPS untis and have hit a problem. I’m using a VK16E GPS (fairly common), GPSTiny+ library and a Uno. I would like the GPS to go and find the location (which I have managed to do), tell the time (ok looking good so far) and finally convert the gps co-ordinates to a maidenhead locator using some simple maths. All this is to be displayed on a 16x2 LCD. Firstly make each bit work, then use a button to cycle through the 3 bit’s of info.
For now I’m stuck how to get the gps co-ordinates into the maidenhead locator. I have commented out the bits I have working but I’m getting stuck defining firstly a test point (my home location) and then will move onto the gps variable.

Error’s are:

gps_time_ino.ino: In function ‘void diplayMaidenHead()’:
gps_time_ino:103: error: ‘lat’ was not declared in this scope
gps_time_ino:104: error: expected ‘,’ or ‘;’ before ‘lat’
gps_time_ino:105: error: redeclaration of ‘int var’
gps_time_ino:103: error: ‘int var’ previously declared here
gps_time_ino:105: error: ‘lon’ was not declared in this scope
gps_time_ino:123: error: expected `)’ before ‘;’ token
gps_time_ino:126: error: ‘MH_txt’ was not declared in this scope

I’m guessing there’s a simple mistake but I’m struggling after looking at it for a couple of hours

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>
/*
   This sample sketch demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 8(rx) and 9(tx).
*/
static const int RXPin = 8, TXPin = 9;
static const uint32_t GPSBaud = 9600;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup()
{
  ss.begin(GPSBaud);
  lcd.begin(16,2);

  lcd.setCursor(1,0);
  lcd.print("Tiny GPS+ Time");
  delay(3000);
  lcd.setCursor(1,2);
  lcd.print("by Alex, g7kse");
  delay(5000);
  lcd.clear();
 
}

void loop()
{
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
 //     displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    lcd.print("No GPS detected");
    while(true);
    }
  }

//***************************************************************************//
// GPS Lat & Long
//void displayInfo()
//{
// 
//  if (gps.location.isValid())
//  {
//    lcd.setCursor(0,0);
//    lcd.print("Lat: "),lcd.print(gps.location.lat(), 3);
//    lcd.setCursor(1,0);
//    lcd.print("Lon: "),lcd.print(gps.location.lng(), 3);
//  }
//  else
//  {
//    lcd.print("INVALID");
//  }
//
//}

//***************************************************************************//
// Time Information
//void displayTime()
//{
//lcd.setCursor(4,0);
//  {
//    if (gps.time.hour() < 10) lcd.print(F("0"));
//    lcd.print(gps.time.hour());
//    lcd.print(F(":"));
//    if (gps.time.minute() < 10) lcd.print(F("0"));
//    lcd.print(gps.time.minute());
//    lcd.print(F(":"));
//    if (gps.time.second() < 10) lcd.print(F("0"));
//    lcd.print(gps.time.second());
// 
//  }
//lcd.setCursor(3,2);
//  {
//    if (gps.date.day() < 10) lcd.print(F("0"));
//    lcd.print(gps.date.day());
//    lcd.print(F("/"));
//    if (gps.date.month() < 10) lcd.print(F("0"));
//    lcd.print(gps.date.month());
//    lcd.print(F("/"));
//    lcd.print(gps.date.year());
//  }
//
//}
//*********************************************************************************//
//Maidenhead Locator//
void diplayMaidenHead(){

//#ifdef Demo
   /*  Set up the dummy location. Used for testing */
 int var = lat
 lat = -3588367;                               //  West 3.588367 deg 
 int var = lon
 lon = 54487476;                               //  North 54.487476 deg
  
//DiagNum("Lat is : ", lat);
//DiagNum("Lon is : ", lon);
//#endif

{

//ln = (gps.location.lng(), 3) + 18000000;                            // Step 1
//lt = (gps.location.lat(), 3) +  9000000;                            // Adjust so Locn AA is at the pole

char MH[6] = {'A', 'A', '0', '0', 'a', 'a'};     // Initialise our print string
  MH[0] += (lon / 2000000);                       // Field
  MH[1] += (lat / 1000000);
  MH[2] += (lon % 2000000) / 200000;             // Square
  MH[3] += (lat % 1000000) / 100000;
  MH[4] += (lon %  200000) /   8333;             // Subsquare .08333 is   5/60 
  MH[5] += (lat = "";                              // Build up Maidenhead
int i = 0;                                       // into a string that's easy to print
while (i < 6){ 
  MH_txt += MH[i];
  i++; }

#ifdef sprnt
lcd.setCursor(0,1);
lcd.print("Maidenhead : ");
lcd.println(MH_txt);
#endif

lcd.setCursor(1,0);                            // Where do we want this to display?
lcd.print(MH);
 
  return;
}
}
 int var = lat
 lat = -3588367;                               //  West 3.588367 deg 
 int var = lon

You missed a few of these: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Feel free to borrow some of my extras.

gps_time_ino:103: error: ‘lat’ was not declared in this scope

So, in what scope IS lat defined?

I knew I needed a few of those. Can you stick a few in a jiffy bag and send them over?

I didn't get the other error either. I was pointing at the screen and showing it where it was as well. It's here.....can't you see it?

Thanks for helping

Alex

int var = lat

This is not C/C++ lookup the correct way to declare variables in the reference section.

Mark

Cheer Mark, just feeling my way through it.

I was reading in the reference that there can be issues if you put these is the wrong place in the sketch...I'll get there

Alex

The code you wrote says

int var = lat

create/declare a variable called var and assign to it the value (contents) of a variable called lat!. Even with a truck load of ; you will still get an error. to declare lat you say

int lat;

Mark

Thanks again Mark. I'll no doubt miss out a ; somewhere but I can find those.

Alex