Serial.parseFloat() functions will return the next valid number in the incoming serial, or return zero if a valid number was not found.
loop() function is calling the parsing function when
Serial.available() == 0 returns
true, and you are sending a number value through the Serial Monitor with a line ending configured:
- Read the first valid number value in the buffer. Line ending characters will be left in the buffer, and
Serial.available() == 0will return
- If the function is called again before a new number value has been added to the buffer, it will return zero.
You can solve the problem by:
- Selecting No line ending in the Serial Monitor.
- Using the Serial.read() and define your own logic for reading the buffer.