0

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

1 Answer 1

1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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