Uno rebooting

Hey everyone,

I'm trying to send some GPS coordinates to my Uno board using the serial port. I begin by sending a start command by sending . Then, each coordinate I send is also enclosed in <> and the latitude and longitude are separated by a comma with no space. After all the coordinates have been received, I send a stop command by sending . So, I need to parse the coordinates out. I want to save the coordinates into the EEPROM, but I haven't implemented that because I am trying to figure out why my board keeps rebooting.

Here is my code:

void loop() {

while(Serial.available() > 0) {
    inChar = Serial.read();
    if(inChar  == '<') {
      memset(inData, 0, sizeof(inData));
      readSerial = true; 
      charNum = 0;
    }
    if(readSerial) {
      inData[charNum] = inChar;
      charNum++;
    }
    if(inChar == '>') {
      charNum++;
      inData[charNum] = '\0';
      readSerial = false;
      break;
    }

if(strcmp(inData, "<stop>") == 0) {
    readInCoordinates = false; 
  }
  if(strcmp(inData, "<start>") == 0) {
    Serial.println("read in coordinates");
    readInCoordinates = true;
  }
  }

void parseCoordinates() {
  int parseNum = 1;
  int latNum = 0;
  int lonNum = 0;
  char lat[20];
  char lon[20];
  boolean parseLat = true;
  if(strcmp(inData, "<start>") != 0) {
    while(inData[parseNum] != '>' && strcmp(inData, "<start>") != 0 && strcmp(inData, "<stop>") !=0) {
      if(inData[parseNum] == ',') {
        parseLat = false;
        parseNum++;
        lat[latNum] = '\0';
      }
      if(parseLat) {
        lat[latNum] = inData[parseNum];
        latNum++;
      }
      else {
        lon[lonNum] = inData[parseNum]; 
        lonNum++;
      }
      lon[lonNum+1] = '\0';
      parseNum++;
    }
    Serial.print("lat: ");
    Serial.println(lat);
    Serial.print("lon: ");
    Serial.println(lon);
  }
}

Thanks everyone!

http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection

Hmm... Well, I don't want to start modifying my board. Why does the serial connection keep getting cut then re-established?

Hmm... Well, I don't want to start modifying my board

Didn't bother reading the top part of that webpage, eh?

Why is the serial connection keep getting cut then re-established?

On one end of the serial connection is your Arduino. What is on the other end? A PC? The serial port of a PC?

What I meant is I don't really want to start messing with my board, even if I just involves bridging a couple of pins

Anyways, the board is connected via USB to my computer.

Anyways, the board is connected via USB to my computer.

Good. That eliminates one problem. Now for the other one...

What I meant is I don't really want to start messing with my board, even if I just involves bridging a couple of pins

You don't have a choice. Opening a serial connection to an Arduino resets the board.

No mods required, see:

Stick a 120 ohm resistor in the headers between 5v and reset (you can find these on the isp connector too). 120 is hard to find so just combine resistors. Don't go below 110 ohms or above 124 ohms, and don't do this with an isp programmer attached. You can just pull out the resistor when you want auto-reset back.

BTW Why is the resistor value so critical? What if someone were to use 100 ohms or 220?

I've used 1k and 10k's before without issue, while that may or may not cause an issue, I don't know...

You can use a small electrolytic capacitor between Gnd and reset, anywhere from 1uF to 47uF works fine. Its all about holding the reset line high against the auto-reset circuit which is just a low pulse from a 100nF capacitor. The larger value electrolytic just swallows the pulse, swamping it with the high its storing. The resistor does the same thing, but it has no storage so it does it by brute force, hence the low and intolerant value.