Thermal receipt printer
Thermal receipt printer
What I wanted to learn, and why it interested me: I wanted to learn how to use a motion detector, and use it as the signal to print text through a thermal receipt printer. It's interesting to me because so many automative processes are triggered by motion in daily life, specifically motion of human body, like the water fountain for example. A thermal receipt printer interests me because it outputs something physical and that I can manipulate the text to make it personal.
Final outcome: A thermal receipt printer printing out a text for my roommate, triggered by human motion.
Images of final creative/exploratory output
When motion is detected by the Passive Infrared Sensor, the Thermal Receipt Printer prints a note for my roommate, which says "Hello roommate, Hello roommate, Good morning roommate, Have a nice day roommate."
Process images from development towards creative/exploratory output
The thermal receipt printer printed weird, unreadable text. I fixed it by initializing SoftwareSerial to 9600 baud rate.
Adjusting the delay and sensitivity of the passive infrared sensor.
Process and reflection:
I started exploring the thermal receipt printer by printing the test page and checking what baud rate my printer is. Then, I wired up two buttons, one triggers the printer to print a short poem, the other triggers the printer to print an image of a house. It was really fun to see the possibility of printing images. However, images with high resolution couldn't be printed, I had to compress my images.
After understanding how to use one component as the digital input trigger to signalize the thermal receipt printer to print, all I had to do was to replace it with the passive infrared sensor. The HIGH/LOW OUTPUT of the sensor goes into the Arduino and then acts as an input to tell the printer whether to print or not. One of the things that I had to ask AI for help was whether the sensor PIN is an INPUT_PULLUP, or just INPUT. I set it to be INPUT_PULLUP so that it "pulls" the pin's voltage up to a steady HIGH state by default.
Everything went pretty smooth with the help of online resources and some AI. I just have to keep reminding myself to understand things that I'm copying from AI.
Technical details
Electrical schematic (the 9V comes from power supply)
#include "Adafruit_Thermal.h"
#include "adalogo.h"
#include "adaqrcode.h"
#include "SoftwareSerial.h"
#define TX_PIN 6 // Arduino transmit YELLOW WIRE labeled RX on printer
#define RX_PIN 5 // Arduino receive GREEN WIRE labeled TX on printer
#define SENSOR_PIN 7 // connects to the infrared sensor signal
SoftwareSerial mySerial(RX_PIN, TX_PIN); // Declare SoftwareSerial obj first
Adafruit_Thermal printer(&mySerial); // Pass addr to printer constructor
void setup() {
pinMode(SENSOR_PIN, INPUT_PULLUP); // (inspired by Gemini)
mySerial.begin(9600); // Initialize SoftwareSerial
//Serial1.begin(19200); // Use this instead if using hardware serial
printer.begin(); // Init printer (same regardless of serial type)
printer.setDefault(); // Restore printer to defaults
}
void loop() {
if (digitalRead(SENSOR_PIN) == LOW) { // (inspired by Gemini)
printer.wake();
delay(100); // (inspired by Gemini)
printer.reset(); // (inspired by Gemini)
printer.setDefault(); // (inspired by Gemini)
printer.println(F("Hello roommate,"));
printer.println(F("Hello roommate,"));
printer.println(F("Good morning rooommate,"));
printer.println(F("Have a nice day roommate."));
printer.feed(3);
printer.sleep();
delay(10000); // (inspired by Gemini)
}
}