Answer the question
In order to leave comments, you need to log in
How to accept Serial parameters on Arduino?
It is necessary to make the arduino accept the code and display the pixel on the display. The display requires 3 parameters: XY and true/false to be enabled. turn off the pixel. How to make reading these parameters into 3 variables? For example: /set 12 34 - will set print(12, 34, 1); And /clr 32 43 - will set print(32, 43, 0); I have already done the reception of the line, it remains only to divide 1 line into 2 variables, and /clr /set will set 1 or 0. How can this be implemented?
Answer the question
In order to leave comments, you need to log in
I was making a command line whose syntax is variable value
int i = inputString.indexOf(" ");//Разделитель строки на подстроки
if (i > 0) {
String command = inputString.substring(0, i);
String paramString = inputString.substring(i + 1, inputString.length());
unsigned long param = paramString.toInt();
Serial.print (command);
Serial.print (" = ");
Serial.println (param);
//Здесь можно чтото сделать с переменными command и param, например, разобрать через switch-case
}
else Serial.println (F("Error: not value"));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question