Question

I'm controlling a serial printer from Arduino. Now it works perfectly, but I need to send it escape characters to control some specific features of the printer. Is there a way to do that?

I need to send "ESC i".

Was it helpful?

Solution

Serial.print(27, BYTE); // ASCII code for the Escape character
Serial.print("i"); 

OTHER TIPS

Escape is ASCII character code 27. If you are programming in C, you could do:

putchar(27);
putchar('i');

Or, if you want to put the whole thing in a string, you could do something like:

printf("\033i");

The \033 will get replaced with 33 octal, which is 27 decimal by the compiler.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top