Randomly Selected Numbers...

This is not doing what it should. It compiles properly… The intent is to pick a random number at start, and display the corresponding lat/lon associated with that number. I believe it’s just an issue in syntax… It is written in a rather convoluted way because it’s just a snippet of a main code, but I’ve modified it to what I believed would work. Sadly, I was wrong.

#include <EEPROM.h>

int RAND;
int LOCATION;
float FINAL_LAT;
float FINAL_LON;

#define ADDR_LOCATION 0

// Location 1
#define LAT_1 1.1234f
#define LON_1 1.4321f

// Location 2
#define LAT_2 2.1234f
#define LON_2 2.4321f

// Location 3
#define LAT_3 3.1234f
#define LON_3 3.4321f

// Location 4
#define LAT_4 4.1234f
#define LON_4 4.4321f

void setup() {
  Serial.begin(9600);
  LOCATION = EEPROM.read(ADDR_LOCATION);
  if (LOCATION == 0) {
    Serial.println("Initializing.\n");
    EEPROM.write(ADDR_LOCATION, random(1,5));
  }

  if (LOCATION == 1) {
    FINAL_LAT = LAT_1;
    FINAL_LON = LON_1;
    Serial.print("Lat: ");
    Serial.println(FINAL_LAT);
    Serial.print("Lon: ");
    Serial.println(FINAL_LON);
    Serial.print("LOCATION: ");
    Serial.println(LOCATION);
  }
  else if (LOCATION == 2) {
    FINAL_LAT = LAT_2;
    FINAL_LON = LON_2;
    Serial.print("Lat: ");
    Serial.println(FINAL_LAT);
    Serial.print("Lon: ");
    Serial.println(FINAL_LON);
    Serial.print("LOCATION: ");
    Serial.println(LOCATION);
  }
  else if (LOCATION == 3) {
    FINAL_LAT = LAT_3;
    FINAL_LON = LON_3;
    Serial.print("Lat: ");
    Serial.println(FINAL_LAT);
    Serial.print("Lon: ");
    Serial.println(FINAL_LON);
    Serial.print("LOCATION: ");
    Serial.println(LOCATION);
  }
  else if (LOCATION == 4) {
    FINAL_LAT = LAT_4;
    FINAL_LON = LON_4;
    Serial.print("Lat: ");
    Serial.println(FINAL_LAT);
    Serial.print("Lon: ");
    Serial.println(FINAL_LON);
    Serial.print("LOCATION: ");
    Serial.println(LOCATION);
  }

  reset();
}

void loop() {
}

void reset() {
  delay(10000);
  EEPROM.write(ADDR_LOCATION, 0);
}

Unless you do something to initialize the generator, it always starts at the same value and returns the same sequence of values. There are several variations of seeding algorithms on the forum but, from what I can tell, they all have deficiencies. Given that you're already using the EEPROM, I suggest this...

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1283911573/7#7

Hmmm... to be honest I can't understand much of that code. I read the replies below in which you gave an overview, and that didn't help much. This is my first time writing programs for Arduino at all... so anything beyond the basic just confuses me. I would just copy it, but I don't necessarily want to do that until I know what it means in case I need to do something similar in the future. If someone has the time, perhaps they can provide a more easy to understand overview than the one posted in that thread...? I'd appreciate it.

Do you understand how a pseudo random number generator works (like random)?

If there is a value that is not 0 in EEPROM location 0

LOCATION = EEPROM.read(ADDR_LOCATION);

than there will never be written a random value in it.

And if there is 0 in it will be replaced with a random value 1..4 and it never will be changed thereafter.

You need a sheet of paper and place the names of the variables at top of it. Follow your code line by line and write in colums the effect of it. "restart a few times" to get the insight of your code.