Phew, where to begin...
- void move(int x = 0,int y = 0,int s = 0); //Not sure why this needs to be done ???
This is a function prototype. The Arduino IDE handles these for you, so typically these are not necessary.
- move(x, y, s); // DO NOT UNDERSTAND "move()"
It's just a call to the function with the provided values.
if( Serial.available()) // if data is available to read, this is how to check the serial part for strings
characters, not strings.
char c= Serial.read(); // the string in serial read() is buffered in to c as characters
the character is read, not the string
if (c == ','){ //look at the incoming chars, if it is a ',' then switch the case
currentCommand++; //for some reason currentCommand increments????
}
If the character is a deliminator (comma in this case) increment the number of commands received.
else { //if it is not ',' then store chars in string, keep storing the string until a , is found
val += c; // same as (val + c = c)val is the next string + the previous character stored in buffer
//Serial.println(val);
If it's not a comma, concatenate it onto the String val (note the difference in capitalization, String and string are not the same thing).