Note the [ shighlight] and the [ /shighlight] these are inserted into the code block to Highlight the word you are searching for, "atoi", Take that out and get rid of the 2 extra }} at the bottom and it should compile.

// this program decodes a clock string sent via XBee radio// the end result is six integer variables that hold the current year, month, day, hour, minute and second//// the time string is in the following format:// *20061003143227// where the year is 2006, month is October, day is the 3rd, hour is 14 (2 p.m.), minute is 32 and second is 27//// by Rob Faludi// http://www.faludi.com

if (inByte == '*') { // if we got the correct start character (instead of a timeout) timeStringValid = true; // declare and initialize a variable to track whether the string has all valid characters long startTime = millis();//makes the start time = to now int timeout = 1000; // timeout after one second while(millis() - startTime < timeout && Serial.available() < 14) { ; //wait for enough data to be available (14 characters of time string), while doing nothing else } for (int i=0; i < 14; i++) { timeString[i] = Serial.read(); // reach each time string character into a character array if(timeString[i] < '0' || timeString[i] > '9') { timeStringValid = false; // if any character is bad then the whole string is bad } } softSerial.print("Time: "); softSerial.println(timeString); }

if (timeStringValid == true) { char yearString[5]; // create a string to hold the year part of the string memset(yearString,'\0',5); // initialize that string to all NULL characters strncpy( yearString, timeString, 4); // copy the first four characters of timeString into the year string year = atoi(yearString); // convert ASCII year string to integer and store in the year integer variable softSerial.print("Year: "); softSerial.println(year, DEC);

char monthString[3]; // create a string to hold the month part of the string memset(monthString,'\0',3); // initialize that string to all NULL characters strncpy( monthString, timeString+4, 2); // skip four characters, then copy the next two of timeString into the month string month = atoi(monthString); // convert ASCII month string to integer and store in the month integer variable softSerial.print("Month: "); softSerial.println(month, DEC);

///////////////////////////////// UTILITY FUNCTIONS //////////////////////////////////////////// this function checks for a specific response on the serial port// it accepts a string to look for and a timeout in millisecondsint checkFor(char* desiredResponse, int timeout) { int result = 0; int length = 40; char incomingResponse[41]; memset(incomingResponse,0,length); // initialize all incomingResponse string positions to null char inByte = NULL; long startTime = millis();//makes the start time = to now char* ptr_incomingResponse = incomingResponse; // while we haven't timed out or gotten back the string that we are looking for while (millis() - startTime < timeout && strstr(incomingResponse,desiredResponse) == NULL ) { //strstr compares strings if (Serial.available() > 0) { // if there are any bytes waiting to be read inByte = Serial.read(); // read one byte if (incomingResponse > ptr_incomingResponse-length) { // if we haven't read in 80 characters yet *ptr_incomingResponse = inByte; // put the byte into the current position in the string ptr_incomingResponse++; // advance to the next position in the string } else { //move the last char to be next to last, and so forth until we reach the end of the array. for (int i = 0; i < length; i++) { incomingResponse[i] = incomingResponse[i+1]; } incomingResponse[length-1] = inByte; // put the byte into the current position in the string } } } softSerial.println(incomingResponse); if (strstr(incomingResponse,desiredResponse) != NULL ) { // if the desired string is found result = 1; } else { result = 0; } return result;}

// this function blinks the an LED light as many times as requestedvoid blinkLED(int targetPin, int numBlinks, int blinkRate) { for (int i=0; i<numBlinks; i++) { digitalWrite(targetPin, HIGH); // sets the LED on delay(blinkRate); // waits for a blinkRate milliseconds digitalWrite(targetPin, LOW); // sets the LED off delay(blinkRate); }}

The reason that atoi is returning such unexpected numbers for you is that it returns an int, which in Arduino-land is 16-bits and limited to a maximum value of 32767. If you use atol, which uses long instead, that may improve things.