PaulS:
You are printing ltr and val even when started and ended are not true.Read the code; try to understand what it is doing. Don't just stick new stuff in anywhere.
Right. I had mentioned that in previous post but i edited it in there. I put the if statements inside the if(started && ended). It seems to work now but it executed for about 5 seconds pretty well but decided to not read anything from the pot after that. Not sure what happened. Here is a sample and then it decided to not print anything.
This is letter: A
<402>
This is letter: A
<408>
This is letter: A
<414>
This is letter: A
<420>
This is letter: A
<426>
This is letter: A
<432>
if(started && ended)
{
ltr = ' ';
if(strlen(string) > 0)
{
ltr = string[0];
string[0] = ' ';
//val=atoi(string);
}
//convert portion of string to integer representation
val=atoi(string);
if(ltr == 'A')
{
Serial.print("This is letter: ");
Serial.println(ltr);
Serial.print("<");
Serial.print(val);
Serial.println(">");
}
else if(ltr == 'B')
{
Serial.print("This is letter: ");
Serial.println(ltr);
}
//next time
started = false;
ended = false;
index = 0;
string[index]='\0';
}