Berfore including something into a large sketch I am testing it in a simple sketch. The same here, the data that comes from a serial.read is here simulated by a charracter arry. The purpose of the if is to test if the received character contains the nu,ber 0-9 and two other charcters being the comma and dot, eg "qwerty,0123456789.\0" => ",0123456789."
The question is, can this be done easier?
if the received string has a space between the cmd and value, sscanf() can be used to read the cmd into a char array and an int. i don't believe the arduino scanf handles floats
That means you should put parentheses in your expression to disambiguate the order of operation: if(!num_keypad && (saByte == ',' || saByte == '.'|| (saByte >= '0'&& saByte <= '9'))) {
warning: 'i' is used uninitialized in this function [-Wuninitialized]
for (int i; i <= 20; i++) {
^
You didn't assign an initial value to 'i' and it is a local variable so it doesn't automatically get set to zero. You have to explicitly initialize it:
' for (int i=0; i <= 20; i++) {`
You can save a little code by not using a variable that never changes ('num_keypad').
Here is a version of your sketch that fixes the errors and warnings and removes the unneeded variable.
undefined, but beyond the end of the current string but available if you wanted to add additional characters. If you actually did print them out, they most likely would be '\0'