I am currently working on a project and I want to send image data to a thermal printer module. I only have access to Data pin, Clock pin and LAT pin. I should send data bytes with every rising edge of the Clock. my questions are:
1- should I produce a Clock signal? How should I do it correctly?
2- is there any function to use for sending Data to a pin? for example I want to send image data which is turned into HEX, to Data pin.
Can you post a link to a description (technical data sheet) of the thermal printer ?
Yes, you can send such serial data to a device connected to an Arduino pin. The command digitalWrite() is the most basic way.
Also google for "arduino thermal printer"
In the example you found at Faster Shiftout, how? - Programming Questions - Arduino Forum, the user was attempting to use shiftOut() to send data to the pin. In this case he is sending the constant B11111111.
You'd want to send data[ i ] instead if you are using this array:
byte data[ ]={0xff,0xff,0xff,0xff,0x00,0x01,0xff,0xff,0xff,0xf8,0x01,0xff,0xff,0xff,0xff,0xc0,0x07,0xff,0xff,0xff,0xff,0x00,0x01} ;
void Write() {
digitalWrite(latchPin, HIGH);
for (int i = 1; i <= 48; i++) {
shiftOut(dataPin, clockPin, MSBFIRST, B11111111);
}
digitalWrite(latchPin, LOW);
}
shiftOut() handles the clock pin, signalling to the device (thermal printer in your case) that a data bit can be read. You don't manipulate it explicitly yourself.