SOLVED:
You can change the char buffer by using:
char *arg;
arg = SCmd.next();
int i;
sscanf(arg, "%d", &i);
Serial.print("String value ");
Serial.println(arg);
Serial.print("Integer value ");
Serial.println(i);
PROBLEM:
I can't seem to figure out how to change a char buffers contents to an integer from a stored string.
For instance:
'1' should be 1,
'121' should be 121
Here's what I tried.
void doIt()
{
char *arg;
arg = SCmd.next(); // Get the next argument from the SerialCommand object buffer
if (arg != NULL) // As long as it existed, do it
{
int argInted = (int)arg; // Cast char arg* -> int argInted.
Serial.print("String value ");
Serial.println(arg);
Serial.print("Integer value ");
Serial.println(argInted); // Print this new found integer.
}
else {
Serial.println("Fix your arguements");
}
}
Here's what I get, it evaluates to 371 every time. I'm storing different things in the pointer buffer though, any ideas on how to convert?
Arduino Ready
> INPUT 1
String value 1
Integer value 371
> INPUT 2
String value 2
Integer value 371
> INPUT WHATSthisDO
String value WHATSthisDO
Integer value 371