Conditional information displayed on serial monitor

This might be a step too far, but wondered if it was possible to change the text colour displayed on the serial monitor depending on the value of the information coming from Arduino. For instance if a sensor measures a temperature, could the text colour be changed if it rises above a certain level?

Thanks in advance!

S

It's not possible with the Arduino IDE's Serial Monitor. However, if you use a terminal program that does VT100 emulation, you should be able to control color by sending the appropriate ANSI escape codes. I've never tried it but there was some discussion on the topic in the Arduino Developers mailing list.

Can anyone help me in terms of using ANSI escape codes with Arduino? There is a Library Ansiterm.h but not sure how to get that into Arduino? Any I have done before have been ZIP files.

I can't find any sample code on how to use ANSI with Arduino

Thanks in advance

S

I found the ansiterm library zip file, extracted and copied it into the libraries folder in Arduino and when opening up Arduino afterwards it says it's an invalid library. Any thoughts?

S

Please post a link to where you downloaded the zip file from.

pert:
Please post a link to where you downloaded the zip file from.

This is where I downloaded it from GitHub - rklancer/ansiterm: Bruce Robertson's Arduino library for emitting ANSI terminal codes, extracted from his qrpTracker library

The library folder must be directly under the libraries folder, not in a subfolder. It's common for people to structure their repositories with the library is in the root so that it can be easily installed. Unfortunately that is not the case with this library. So to fix the error you just need to move the library folder up one folder level. The installed folder structure should look like this:

{sketchbook folder}
|_libraries
|_ansiTest
|_Ansiterm.h
|_Ansiterm.cpp

I'm guessing yours currently looks like this:

{sketchbook folder}
|_libraries
|_ansiterm-master
|_ansiTest
|_Ansiterm.h
|_Ansiterm.cpp

Why would one need a library to send VT100 escape codes?

...R

pert:
The library folder must be directly under the libraries folder, not in a subfolder. It's common for people to structure their repositories with the library is in the root so that it can be easily installed. Unfortunately that is not the case with this library. So to fix the error you just need to move the library folder up one folder level. The installed folder structure should look like this:

{sketchbook folder}
|_libraries
|_ansiTest
|_Ansiterm.h
|_Ansiterm.cpp

I'm guessing yours currently looks like this:

{sketchbook folder}
|_libraries
|_ansiterm-master
|_ansiTest
|_Ansiterm.h
|_Ansiterm.cpp

Thanks for your reply, all sorted now!

S

I'm glad to hear it. Are you able to get color output on puTTY now?

pert:
I'm glad to hear it. Are you able to get color output on puTTY now?

Yes thanks, I can get the colours working fine now! Unfortunately the library does not have a blinking option but getting the colours are a big help. Much appreciated.

Thanks again

S

pert:
I'm glad to hear it. Are you able to get color output on puTTY now?

Robin2:
Why would one need a library to send VT100 escape codes?

...R

Only because I couldn't find anywhere that showed me how to write the Arduino code for the escape codes! If you could point me to a post or source, that would be great.

Thanks

S

SierraGolfMike:
Only because I couldn't find anywhere that showed me how to write the Arduino code for the escape codes! If you could point me to a post or source, that would be great.

I suggested a Google search in your other Thread 2 days ago.

...R

I have searched Google and can find sample code for Python Bash etc. but none for Arduino, except one line of code that did not work.

SierraGolfMike:
I have searched Google and can find sample code for Python Bash etc. but none for Arduino, except one line of code that did not work.

Did you try the Google search that I suggested?

...R

Robin2:
Did you try the Google search that I suggested?

...R

Yes I did Google VT 100 escape codes and found a few pages but none of them showed how to adapt them to Arduino! I have found a sample sketch where they use a

#define BLINK "\033[5m" Then:

Serial.print (BLINK); I assume that switches BLINK on and anything printed after will blink?

Am I correct in thinking that if I define all the codes I need, I just invoke them by using a Serial.print statement? Also can I use these in conjunction with Ansiterm, using some of each code.

Thanks

S

SierraGolfMike:
Am I correct in thinking that if I define all the codes I need, I just invoke them by using a Serial.print statement?

That is how I would go about it.

Also can I use these in conjunction with Ansiterm, using some of each code.

I don't know what Ansiterm is.

...R

I tried to run Rob Tillaart's VT100 sketch where he defines OFF. BOLD, LOWINTENS, UNDERLINE, BLINK and REVERSE using the relevant ANSI escape codes. I am using PuTTY but the BLINK and the LOWINTENS do not work, the rest do The BLINK just gives a background colour of grey. Does that mean that PuTTY does not support them?

SierraGolfMike:
Does that mean that PuTTY does not support them?

You will have to read the PuTTY documentation for that.

...R