Answer the question
In order to leave comments, you need to log in
How to divide Char into an array by sign in Arduino?
Hello, I have a question with Arduino.
How to transfer several int variables over the Serial port. For example [1 45 67 94 23 543].
As I understand it, only a Char string can be transferred via Serial. How can I convert it to an int array with a width of 6, if the numbers of the transmitted string are separated by spaces.
PS As I understand it, there is no Split in the Arduino IDE.
Thank you in advance.
Answer the question
In order to leave comments, you need to log in
Collect from char`s string:
char inChar = (char)Serial.read();
inputString += inChar;
if (inChar != '\n' or inChar != '\r'){
int i = inputString.indexOf(" ");
if (i > 0) {
String command = inputString.substring(0, i);//The part of the string about spaces
String paramString = inputString.substring(i + 1, inputString.length());//This is the part of the string after the space
unsigned long param = paramString.toInt();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question