I have code for reading strings from Serial. My problem is when i first time sent servo:randomint normal work, but when I sent second time string* does not change the value.
What the heck are you pissing away resources like this for?
You need to post ALL of your code. There is no evidence that you ever reset x, so the next string does not go at the beginning of matrix, so the next str processing just extracts the same data.
There is NO reason to be using Strings. All the functionality that Strings offer are because strings off the same functionality.
AWOL:
Reading stuff from the serial port when there's nothing there to read is rarely a good idea.
(That was just a snippet of my full answer)
Why?
PaulS:
String s = String(matrix[x] ,DEC);
What the heck are you pissing away resources like this for?
You need to post ALL of your code. There is no evidence that you ever reset x, so the next string does not go at the beginning of matrix, so the next str processing just extracts the same data.
There is NO reason to be using Strings. All the functionality that Strings offer are because strings off the same functionality.
Rettiwer:
My problem is when i first time sent servo:randomint normal work, but when I sent second time string* does not change the value.
That is because you don't reset the index 'x' to 0 after you use the value in 'matrix'. You add new characters to the END of 'matrix' (eventually causing a crash) but when you convert 'matrix' to a string it always uses the first string in 'matrix'.