So, I was looking out for a better print statement, one that could manage a whole string of parameters, just like I’m used to.

(Now I understand why the folks developing the code didn’t include it – the overhead of a regular print statement is pretty big, since it’s kind of a ‘kitchen sink’ tool. But for debugging it makes code much cleaner, and shorter – so I wanted one.)

Finally, after wondering on my own for far longer than I want to admit, I found one online (typical). It was on the Arduino forum, and was a simple buffer-style print:

It’s almost ready to use – almost. One problem is that the buffer is not null terminated if it goes too long – a big no-no. Another is that the code assumes a Serial object – what if you’d rather use another serial object?

The format is just like a typical print statement, but to the Serial object you choose. And if you worry about the buffer size, feel free to change its size from 128. Also, there’s no more need for a newline version, as you can just use the entry n in your string to force a newline.

Or, if you’re determined to use the current serial object, the same code can be a bit lighter: