How do I put the sensor value and text on the one line in the serial monitor.
I just want Pot Value 30 to show in the serial console. What am I doing wrong?
Serial.println("POT value ")(sensorValue);
You just do two Serial prints:
Serial.print("POT value ");
Serial.println(sensorValue);
The .print
prints without moving to a new line, the .println
moves to a new line.
If you want to be more fancy and don't mind the processing and memory overhead, you can use snprintf
to format the string:
char temp[15];
snprintf(temp, 15, "POT value %4d", sensorValue);
Serial.println(temp);
You can read more about sprintf
and formatting here:
Note that there is no floating point support in the standard library for the Arduino - so you can't use %f etc.