Thermal printer pattern maker
Zoe bartholomew
Zoe bartholomew
What I wanted to learn, and why it interested me: For this project, I chose to work with a thermal printer.I wanted to make a pattern maker because I was interested in making something that can produce images. I also wanted something that can be easily customized for the user. I thought that a thermal printer was interesting because of its ability to quickly print out text and i wanted to figure out how to take advantage of that.
Final outcome:I made a pattern printer with each button representing a symbol the user can choose from. There are two star shapes, a smiley face, and a heart. With these ascii shapes you can make a pattern that's any length or order you want.
Images of final creative/exploratory output
Process and reflection: For this project, I got images of some basic shapes through an ASCII art generator. I then realized that my images could easily be too big or distort when printed, so then I started to make my own adjustments to the shapes until each output was legible. I feel like I am now more familiar with the limitations of the thermal printer and learning how to work around the issues, like the speed at which it prints and the limited number of characters you can use on each line because of the size of the paper that it’s printed on.
Technical details
Electrical schematic
#include <SoftwareSerial.h>
#include <avr/pgmspace.h>
#include "Adafruit_Thermal.h"
const int BUTTONPIN1 = 2;
const int BUTTONPIN2 = 3;
const int BUTTONPIN3 = 4;
const int BUTTONPIN4 = 5;
SoftwareSerial mySerial(8,9);
Adafruit_Thermal printer(&mySerial);
const char art1[] PROGMEM =
" + = \n"
" . :+ \n"
" .: .- +. \n"
" .. @# = \n"
" - .@@ - . \n"
" @@@% = \n"
" @@@@@% \n"
" -%@@@@@@@@#: \n"
" :+%@@@@@@@@@@@@@@@@@@#=. \n"
" .*@@@@@@@@@@@@= \n"
" -@@@@@@ \n"
" @@@@ \n"
" = -@@ . \n"
" :@: @@ .@+ \n"
" -- *- + \n"
" . \n";
const char art2[] PROGMEM =
" @@ \n"
" -@@= \n"
" @@@@ \n"
" @@@@@@@@@@@@@@@@ \n"
" +@@@@@@@@@@* \n"
" @@@@@@@@ \n"
" =@@@@@@@@= \n"
" @@# #@@ \n"
" @ @ \n";
const char art3[] PROGMEM =
" -%#+--+#%- \n"
" #+ +#. \n"
" -% #= \n"
" :+ @% #@ +- \n"
" #: .@% #@. .#. \n"
" @ % \n"
" #: =%- -%= .# \n"
" :+ -# *- +- \n"
" =% +@+..+@+ #= \n"
" #= =#. \n"
" -@#+--+#@- \n";
const char art4[] PROGMEM =
" ** ** \n"
" ******** ******** \n"
" ******************** \n"
" ******************** \n"
" ******************** \n"
" ******************* \n"
" **************** \n"
" ************ \n"
" ******** \n"
" **** \n";
void printFromFlash(const char *art) {
char c;
while ((c = pgm_read_byte(art++)) != '\0') {
mySerial.write(c);
}
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
mySerial.begin(19200);
printer.begin();
pinMode(BUTTONPIN1, INPUT_PULLUP);
pinMode(BUTTONPIN2, INPUT_PULLUP);
pinMode(BUTTONPIN3, INPUT_PULLUP);
pinMode(BUTTONPIN4, INPUT_PULLUP);
}
void loop() {
if (digitalRead(BUTTONPIN1) == LOW){
printFromFlash(art1);
while (digitalRead(BUTTONPIN1) == LOW) {}
delay(50);
}
if (digitalRead(BUTTONPIN2) == LOW){
printFromFlash(art2);
while (digitalRead(BUTTONPIN2) == LOW) {}
delay(50);
}
if (digitalRead(BUTTONPIN3) == LOW){
printFromFlash(art3);
while (digitalRead(BUTTONPIN3) == LOW) {}
delay(50);
}
if (digitalRead(BUTTONPIN4) == LOW){
printFromFlash(art4);
while (digitalRead(BUTTONPIN4) == LOW) {}
delay(50);
}
}