Hello friends!
I have an interesting project that I'm trying to finish. My project is associated with an attempt to print an image on a thermal printer by Arduino.
I connected the printer to the Arduino board, wrote my sketch and brought to print easy image. Its just line or pionts. But when I decided to print text or an image, it did not work out.
Please tell me how can I fix my sketch for printing text or images on the Arduino?
#define STP 2
#define DIR 3
#define DSTL 8
#define DSTR 9
#define LATCH 10
#define CLK 11
#define DAT 12
void setup()
{
int v = 0;
pinMode(STP, OUTPUT);
pinMode(DIR, OUTPUT);
pinMode(DSTL, OUTPUT);
pinMode(DSTR, OUTPUT);
pinMode(LATCH, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(DAT, OUTPUT);
digitalWrite(STP, LOW);
digitalWrite(DIR, HIGH);
digitalWrite(DSTL, LOW);
digitalWrite(DSTR, LOW);
digitalWrite(LATCH, HIGH);
digitalWrite(CLK, LOW);
digitalWrite(DAT, LOW);
Serial.begin(115200);
}
void stepper(unsigned int Step, int Speed, boolean Set) {
digitalWrite(DIR, Set);
for (int i = 0; i < Step; i++) {
digitalWrite(STP, HIGH);
delayMicroseconds(Speed);
digitalWrite(STP, LOW);
delayMicroseconds(Speed);
}
}
void loop() {
byte masks[130] = {B00110000, B01001010, B01001010, B01001010, B01111100, B01111111, B01001000, B01001000, B01001000, B00110000, B00111100, B01000010, B01000010, B01000010, B00100100, B00111000, B01000100, B01000100, B01000100, B01111111, B00111100, B01001010, B01001010, B01001010, B00101100, B00001000, B01111100, B00001010, B00001010, B00000010, B00111100, B01000010, B01010010, B01010010, B00110100, B01111110, B01001000, B01001000, B01001000, B00110000, B00000000, B00001000, B01111010, B00000000, B00000000, B00000000, B01000000, B01001000, B00111010, B00000000, B01111110, B00010000, B00101000, B01000100, B00000000, B00000000, B00000010, B00111110, B01000000, B00000000, B01111100, B00000100, B01111000, B00000100, B01111000, B01111110, B01001000, B01001000, B01001000, B00110000, B00111100, B01000010, B01000010, B01000010, B00111100, B01111110, B00010010, B00010010, B00010010, B00001100, B01111110, B01001000, B01001000, B01001000, B00110000, B00110000, B01001000, B01001000, B01001000, B01111110, B01001100, B01001010, B01010010, B01010010, B00110010, B00000100, B00111111, B01000100, B01000100, B00000100, B00111100, B01000000, B01000000, B01000000, B01111100, B00001100, B00110000, B01000000, B00110000, B00001100, B00011110, B01100000, B00011000, B01100000, B00011110, B01000010, B00100100, B00011000, B00100100, B01000010, B00100110, B01001000, B01001000, B01001000, B00111110, B01000010, B01100010, B01010010, B01001010, B01000110};
for (int d = 0; d < 8; ++d)
{
for (int d1 = 0; d1<10; ++d1)
{
Serial.print("Burning: ");
for (int i = 0; i < 130; ++i)
{
int v;
for (int j = 0; j < 5; ++j)
{
digitalWrite(DAT, bitRead(masks[i], d) != 0 ? HIGH : LOW);
// digitalWrite(DAT, HIGH);
digitalWrite(CLK, HIGH);
digitalWrite(CLK, LOW);
}
}
Serial.println("Byte reat +1 ");
Serial.println("Close LATCH: ");
digitalWrite(LATCH, LOW);
digitalWrite(LATCH, HIGH);
digitalWrite(DSTL, HIGH);
delay(8);
digitalWrite(DSTL, LOW);
digitalWrite(DSTR, HIGH);
delay(8);
digitalWrite(DSTR, LOW);
digitalWrite(DAT, LOW);
Serial.println(' ');
stepper (10, 400, 0);
}
}
}