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);
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.Sign up to join this community
You just do two Serial prints:
Serial.print("POT value "); Serial.println(sensorValue);
.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; 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.