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 ");

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);

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.

  • Thanks Mate perfect, i have only just started on this. Thanks for your help it worked! – claycode Jun 5 '15 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.