Hello, I’m trying to print using a empressora thermally connected in ARDUINO UNO REV3 however only prints one strange characters.
could inform here in the forum some simple code to print even one line of text.
The printer is this: http://www.diebold.com.br/ProdutoDetalhe.aspx?produto_id=34
The manual that contains the character map is this: http://www.diebold.com.br/mecaf/drivers/Manual%20do%20Firmware%20I4X5101PD5XX-Rev04.pdf
thank you
this is the code I’m using
#include <SoftwareSerial.h>
SoftwareSerial printer(2,3); // Pino TX, RX do max232 que converte TTL para Serial Impressora. http://www.sparkfun.com/images/tutorials/BeginningEmbedded/4-UART/U...
void setup(){
Serial.println("inicio");
Serial.begin(115200);
Serial.println("inicio2");
printer.begin(115200);
Serial.println("inicio3");
}
void loop() {
Serial.println("imprimindo");
delay(5000);
codeHeight(100); //ALTURA DO COD
printPosition(2); //POSICAO DA IMPRESSAO DECIMAL: 2=Abaixo do Codigo
codeWidth(3); //LARGURA DO CODIGO. Valor entre 0 e 6
fontTipe(0); //TIPO DA FONTE. Valor entre 0 e 3
printer.println("(: Win Mídia :)"); //Imprime o valor e clama uma nova linha
char codBuffer[12] = {'9','9','9','9','9','9','9','9','9','9','9','9'}; //Imprime Array
// ===========PRINT BAR CODE ============= //
printer.write(byte(29)); //GS
printer.write(byte(107)); //k
printer.write(byte(0)); //m
for (byte i=0; i<sizeof(codBuffer);i++){
printer.write(byte(codBuffer[i]));
}
printer.write(byte(0)); //Terminador
// ===========END PRINT BAR CODE ============= //
paperFeed(5); //Avanca 5 linhas em branco
cutPaper(); //Corta papel
}
// ***************** CUTPAPER ******************** //
void cutPaper(){ //Corta papel da impressora
Serial.println("corta papel");
printer.write(byte(0x1D));
printer.write(byte(0x56));
printer.write(byte(0x00));
}
// ***************** CODEHEIGHT ******************** //
void codeHeight(byte val){ //ALTURA DO CODIGO
printer.write(byte(0x1D)); //GS
printer.write(byte(0x68)); //h
printer.write(byte(val)); //Altura do Cod Range[0-255]
}
// ***************** PAPERFEED ******************** //
void paperFeed(byte val){ //Avanca Papel qntidade de linhas especificadas na chamda da funcao
for(byte i=0;i<val;i++){
printer.write(byte(0x0A));
}
}
// ***************** ROTATE ******************** //
void rotatePrint(){ //ROTAR
printer.write(byte(0x1B)); //ESC
printer.write(byte(0x56)); //V
printer.write(byte(49)); //n
}
// ***************** POSICAO DA IMPRESSAO DECIMAL ******************** //
void printPosition(byte val){ //POSICAO DO CODIGO DEC
printer.write(byte(0x1D)); //GS
printer.write(byte(0x48)); //H
printer.write(byte(val)); //n
/* ============================= /
[0] Não impresso
[1] Acima do codigo
[2] Abaixo do Codigo
[3] Acima e Abaixo do Codigo
/ ============================= */
}
// ***************** DIRECAO DA IMPRESSAO ******************** //
void printDirection(int val){ //DIRECAO DA IMPRESSAO
printer.write(byte(0x1B)); //ESC
printer.write(byte(0x54)); //T
printer.write(byte(val)); //n
/* ============================= /
[0] Esquerda para a Direita
[1] Base para o Topo
[2] Direita para Esquerda
[3] Topo para Base
/ ============================= */
}
// ***************** FONTE ******************** //
void fontTipe(int val){ //DIRECAO DA IMPRESSAO
printer.write(byte(0x1D)); //GS
printer.write(byte(0x66)); //f
printer.write(byte(val)); //n
/* ============================= /
[0] Fonte A
[1] Fonte B
[2] Fonte c
/ ============================= */
}
// ***************** CODE WIDHT ******************** //
void codeWidth(int val){ //LARGURA DO CODIGO
printer.write(byte(0x1D)); //GS
printer.write(byte(0x77)); //w
printer.write(byte(val)); //n 2< n <6, 68< n <76
}
// ***************** CODE PRINT ******************** //
void setArea(){
printer.write(byte(0x1B)); //GS
printer.write(byte(0x57)); //w
printer.write(byte(255)); //xl
printer.write(byte(255)); //xh
printer.write(byte(255)); //yl
printer.write(byte(255)); //yh
printer.write(byte(104)); //dxl
printer.write(byte(1)); //dxh
printer.write(byte(126)); //dyl
printer.write(byte(6)); //dyh
}
// ***************** VERTICAL PRINT ******************** //
void setMotionUnit(){
printer.write(byte(0x1D)); //GS
printer.write(byte(0X50)); //P
printer.write(byte(0)); //x
printer.write(byte(0)); //y
}