Hello,
I found this beautiful example in the cookbook of Michael Margolis for a SPLIT a string of characters,
/*
* SplitSplit sketch
* split a comma-separated string
*/
2.7 Splitting Comma-Separated Text into Groups | 39
const int MAX_STRING_LEN = 20; // set this to the largest string
// you will process
char stringList[] = "Peter,Paul,Mary"; // an example string
char stringBuffer[MAX_STRING_LEN+1]; // a static buffer for computation and output
void setup()
{
Serial.begin(9600);
}
void loop()
{
char *str;
char *p;
strncpy(stringBuffer, stringList, MAX_STRING_LEN); // copy source string
Serial.println(stringBuffer); // show the source string
for( str = strtok_r(stringBuffer, ",", &p); // split using comma
str; // loop while str is not null
str = strtok_r(NULL, ",", &p) // get subsequent tokens
)
{
Serial.println(str);
}
delay(5000);
It work very well as is presented : stringList char [] = "Peter, Paul, Mary "; //But this is not editable, scalable
I recive a string from GSM SIM900 like this: "# # 12 # 1 # # 13 # 0 # # 14 # 0"
I want to do this:
String text_from_sms = "# # 12 # 1 # # 13 # 0 # # 14 # 0"; // Always two information as a pair, never the same numbers of pair
stringList char [] = text_from_sms / / my string from SMS,
But this does not work 
How to send a valiable to my stringList char [] ?
The value comes from a Android SMS as pair/value like : "# # 12 # 1 # # 13 # 0 # # 14 # 0";
I want something like this
12: 1 = DIGITALOUT pin 12 = On
13: 0= DIGITALOUT pin 13 = 0ff
14: 1 = DIGITALOUT pin 14 = On
and several more for a MEGA, som fifty fields are possible , Always ON / / OFF
Thanks for a future responses 
Henri
These the lines that are doing most of the work in the original program
for( str = strtok_r(stringBuffer, ",", &p); // split using comma
str = strtok_r(NULL, ",", &p) // get subsequent tokens
Investigate the strtok_r function to see whether it is of any help to you splitting the message at the #'s
I already do with my "# # 12 # 1 # # 13 # 0 # # 14 # 0";
and replaced "" by "# #" in strtok_r
It works very well
12 1
13 0, and so on it's OK
the beginning does not work
stringList char [] = "Peter, Paul, Mary " or "Anything, Anything, Anything" MUST be a variable from a SMS
how to write in stringList char [] ?
Tanks mr UKheliBob
The strtok_r() function is the re-entrant version of strtok(). This means that multiple threads can process the same string at the same time. On a single threaded system, this is a useless feature that takes up far more space in Flash than the simpler to use, non-re-entrant version. No one should be using strtok_r on the Arduino.
But this does not work
Of course not. There is a world of difference between a string and a String. They are not even remotely interchangeable.
I already do with my "# # 12 # 1 # # 13 # 0 # # 14 # 0";
Post your code that does not work.
// Teste de split
const int MAX_STRING_LEN = 200; // set this to the largest string
char stringBuffer[MAX_STRING_LEN+1]; // a static buffer for computation and output
char stringList[]= msg ; // an example string;
char *str;
char *p;
strncpy(stringBuffer, stringList, MAX_STRING_LEN); // copy source string
Serial.println(stringBuffer); // show the source string
for( str = strtok_r(stringBuffer, "##", &p); // split using comma
str; // loop while str is not null
str = strtok_r(NULL, "#", &p) // get subsequent tokens
)
{
Serial.println(str);
}
My example won't help you much
In the example the stringList << char [] = "Peter, Paul, Mary"; >> Can not be changed dynamically, it is written in marble, it's not evolutionary with another word, variable, something that comes from somwhere, Not written by hand just once
tanks
This seems to work OK for me
void setup()
{
Serial.begin(115200);
char msg[] = "# # 12 # 1 # # 13 # 0 # # 14 # 0";
char *part;
Serial.println(msg);
part = strtok (msg,"#");
while (part != NULL)
{
Serial.println(part);
part = strtok (NULL, "#");
}
}
void loop()
{
}
The string (note lowercase s) variable can come from anywhere and as long as its format is consistent strok() can be used to split it. The program prints the parts as they are split off but it could equally well be used to ascertain the pin numbers and the required output.
I have to use my # include <String.h> for the entire program,
then :
arduino cannot convert 'String' to 'char*' for argument '1' to 'char* strtok(char*, const char*)'
This seems to be quite common trouble,
I found a lot of questions on the subject on Google
I must use <String.h> and this is where the problem comes
I wanted (loved) use ARRAY [] [] of different sizes, but I'll probably end up with the same problem
This is the beginning of a project, just to learn for fun
I want to draw a window on my smartphon (Samsung S3) and send these commands via SMS to my Arduino MEGA
To do this I use BASICFORANDROID
I already know VB, Delphi Pascal and C #
I work all day with VBA
I use MicroSoft VisualStudio and VISUALMICRO to program ARDUINO, the debugger is useful
Tanks UHHeliBob
I have to use my # include <String.h> for the entire program
No, you absolutely do NOT. Forget the stupid String class, or go learn how to do what you need to do BY YOURSELF.
AHAH I think you're right Pauls, but it's so match work :~
Thanks PaulS
Henri