<3 Fortune Teller <3
<3 Fortune Teller <3
What I wanted to learn, and why it interested me: In desperate time I rely too much on mythical power so I might as well build one myself.
Final outcome: Press the red button to see your fortune of the day printed out on a receipt. It's very accurate.
Images of final creative/exploratory output
What the fortune looks like. A random image and your fortune.
The actual interaction of the device. Once the red button is pressed, the printer will start printing.
Process images from development towards creative/exploratory output
Setting up the printer with some test samples.
Some ideas of the fortune. Was having a hard time printing images.
Process and reflection:
I first tried to figure out the setup of thermal printer. The first printer I got didn't have good printing quality. After I switched to another one it was fine. Then I learned to use the adafruit library to print images. I had to use Processing to convert images to h file first, and the image size shouldn't be bigger than 380px ish.
After the printer is printing what i wanted, I started to write code that can generate random fortune. I designed an array that can randomly pick fortune. I wanted to print a lot of images but arduino only has enough storage for 2. So each fortune will randomly pick between 2 images and an array of fortune.
Technical details
The schematic is pretty straightforward. Thermal printer is powered by an external 9v power. Make sure one of the printer ground is connected with arduino for it to work.
/*
60-223 Intro to Physical Computing, fall 2025
Domain-specific Skill Building exercise: Fortune teller
A button is connected to a thermal printer. When it's pressed, it'll print out your fortune of the day very accurately.
Pin mapping:
Arduino pin | role | details
------------------------------
5 output printer receiver
6 input printer transmission
13 input button
*/
#include "Adafruit_Thermal.h"
#include "SoftwareSerial.h"
#include "img1.h"
#include "img2.h"
// Define pins
#define TX_PIN 6
#define RX_PIN 5
const int houseButt = 13;
SoftwareSerial mySerial(RX_PIN, TX_PIN);
Adafruit_Thermal printer(&mySerial);
// Button state
int housebuttState = 0;
bool printed = false; // prevent multiple prints per press
// Multiple fortunes
const char* fortunes[] = {
"You might get a A+\nin phsy comp",
"You should do your\nlaundry tonight",
"Time to touch some\ngrass",
"You will dream of\nmany cats tonight",
"Past midnight tonight\nyou will turn into a pumpkin",
"Your mom will have a\ngreat day today",
"Some raccoons are\nthinking of you",
"Idk man",
"Your next decision will\nbe questionable",
"NOTHING BEATS A JET2\nHOLIDAY AND RIGHT NOW YOU CAN\nSAVE 50 POUNDS PER PERSON!",
"You shouldnt trust a\nfortune teller",
"Just go home"
};
// Only two images
struct Image {
const uint8_t* data;
uint16_t width;
uint16_t height;
};
Image images[] = {
{ img1_data, img1_width, img1_height },
{ img2_data, img2_width, img2_height }
};
const int numFortunes = sizeof(fortunes) / sizeof(fortunes[0]);
const int numImages = sizeof(images) / sizeof(images[0]);
void setup() {
pinMode(houseButt, INPUT_PULLUP);
mySerial.begin(9600);
printer.begin();
printer.wake();
printer.setDefault();
Serial.begin(9600);
// Seed random generator
randomSeed(analogRead(A0));
Serial.println("Fortune Teller Ready!");
}
void loop() {
housebuttState = digitalRead(houseButt);
if (housebuttState == LOW && !printed) {
printed = true; // lock until release
// Pick a random fortune
int fortuneIndex = random(numFortunes);
// Pick a random image
int imageIndex = random(numImages);
Serial.print("Printing fortune #");
Serial.println(fortuneIndex);
// Print header
printer.inverseOn();
printer.doubleHeightOn();
printer.justify('C');
printer.println(F(" <3 Fortune of the Day <3 "));
printer.doubleHeightOff();
printer.setLineHeight(20);
printer.inverseOff();
// Print the image
printer.justify('C');
printer.printBitmap(images[imageIndex].width, images[imageIndex].height, images[imageIndex].data);
// Print the fortune text
printer.feed(1);
printer.justify('C');
printer.println(fortunes[fortuneIndex]);
printer.feed(4);
delay(1000); // debounce
}
if (housebuttState == HIGH) {
printed = false; // reset for next press
}
}