One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
Because your array1 is constantly being incremented with array2, the only reason it goes back to "One Two" is because array size is just 9 chars. If it was larger u'd get results like "One Two Two Two Two" etc. To accomplish your point you need array1 to return to its original state after printing it to Serial.
Or, probably better, make a temporary array you will strcat these values into and then print it to Serial:
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
One Two
One Two Two
Try the code I gave you, it does work. As i said, you cant strcat(array1,array2) without returning array1 to its previous state after you printed it to serial
And as for:
String('^')//rest of casts
The correct cast syntax is:
(String)'^'//rest of casts
Remember that "ON" and str.substring are already Strings so you dont need to cast them
Its stored in SRAM. The amount of strings you add to each other doesnt have any limit, just the total length of strings, so it doesnt exceed SRAM capacity.
Are you slow ? Did you follow the example that was provided to you in reply #1
Let me try to explain it to you, very simply.
The first time loop( ) executes, it adds the chars from array2, onto the end of array1. THIS CHANGES ARRAY1. The second time through the loop( ), array2 gets added onto the end of array1 AGAIN. Onto the end of the MODIFIED array1 which was already changed in the first iteration of the loop.
That's why you see "One Two Two" on the output. You have also written to memory beyond the 9 characters which you allocated, which will eventually cause a problem.
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
One Two
You do, but after all I guess you dont need a program that just prints "One Two", but you are going to modify it/move to other program to accomplish the real goal. And thats where will it, most likely, crash. For example change array1 size from [5] to its original size [9], or anything else and you will have wrong output.