Create a romantic quote generator using the XIAO ESP32C3 with the XIAO Expansion Board and an OLED display. This project generates love-themed quotes and displays them on an SSD1306 OLED screen when a button is pressed. At startup, a heart splash screen appears to set the mood.
The StoryLove is often expressed through words, but what if technology could help craft the perfect romantic message? Whether you're looking for a heartfelt quote to surprise your partner or just want to add a little spark to your day, this Love Quote Generator is here to help! Imagine a pocket-sized device that generates touching and poetic love messages at the press of a button—perfect for anniversaries, Valentine's Day, or even a daily reminder of affection. This project was inspired by the idea of blending technology with emotion, showing that even circuits and code can convey love. 💖
Hardware RequiredXIAO ESP32C3
- XIAO ESP32C3
XIAO Expansion Board
- XIAO Expansion Board (for easy connections and Display)
The code is based on micropython. You can customize your own quotes by changing the Arrays. Here are the full code of the project
from machine import Pin, SoftI2C
import ssd1306
import random
import time
import framebuf
# Define romance quote parts
beginnings = [
"In your eyes, ", "With you, ", "Since we met, ", "In this world, ",
"When we touch, ", "You are my ", "In every moment, ", "Through it all, ",
"Between us, ", "Forever, "
]
middles = [
"I see forever, ", "time stands still, ", "life feels right, ", "I find peace, ",
"fear disappears, ", "I feel whole, ", "stars align, ", "magic happens, ",
"the world fades, ", "destiny calls, "
]
endings = [
"and I never want to let go.", "because you're my everything.", "this is our story.",
"you're my missing piece.", "our souls connect.", "everything feels perfect.",
"this is true love.", "you're my infinite.", "every moment is precious.", "you're my dream."
]
# Initialize I2C and SSD1306 OLED display
i2c = SoftI2C(scl=Pin(7), sda=Pin(6))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
# Initialize push button
button = Pin(3, Pin.IN, Pin.PULL_UP) # Adjust pin if needed
# 16x16 pixel heart bitmap (each row is 2 bytes: 16 bits)
heart_bitmap = bytearray([
0b00001110, 0b01110000,
0b00111111, 0b11111000,
0b01111111, 0b11111100,
0b11111111, 0b11111110,
0b11111111, 0b11111110,
0b11111111, 0b11111110,
0b01111111, 0b11111100,
0b00111111, 0b11111000,
0b00011111, 0b11110000,
0b00001111, 0b11100000,
0b00000111, 0b11000000,
0b00000011, 0b10000000,
0b00000001, 0b00000000,
0b00000000, 0b00000000,
0b00000000, 0b00000000,
0b00000000, 0b00000000
])
# Function to display heart splash screen
def display_heart():
oled.fill(0) # Clear screen
fb = framebuf.FrameBuffer(heart_bitmap, 16, 16, framebuf.MONO_HLSB)
oled.blit(fb, 56, 20) # Center the heart
oled.text("Love", 50, 40) # Title text
oled.text("Quote Generator", 5, 50) # Title text
oled.show()
time.sleep(2) # Display for 2 seconds
# Function to generate a random romance quote
def generate_romance_quote():
return f"{random.choice(beginnings)}{random.choice(middles)}{random.choice(endings)}"
# Function to split text for OLED display
def split_text(text, max_line_length=16):
words, lines, current_line = text.split(" "), [], ""
for word in words:
if len(current_line) + len(word) + 1 <= max_line_length:
current_line += word + " "
else:
lines.append(current_line.strip())
current_line = word + " "
lines.append(current_line.strip())
return lines
# Function to display quote on OLED
def display_quote(quote):
oled.fill(0)
lines, y = split_text(quote), 0
for line in lines:
oled.text(line, 0, y)
y += 10 # Move text down
if y > 54:
break
oled.show()
# Show the heart splash screen at startup
display_heart()
# Main loop
while True:
if button.value() == 0: # Button is pressed (active low)
quote = generate_romance_quote()
display_quote(quote)
time.sleep(0.5) # Debounce delay
while button.value() == 0: # Wait for button release
pass
time.sleep(0.1)
✅ Displays a heart-shaped splash screen at startup
✅ Randomly generates romantic quotes
✅ Uses a push button to display new quotes
✅ Compact and easy to build with XIAO Expansion Board
How It WorksOn startup, a heart icon appears as a splash screen.
- On startup, a heart icon appears as a splash screen.
Press the button to generate a new romantic quote.
- Press the button to generate a new romantic quote.
The quote is split into readable lines for the OLED display.
- The quote is split into readable lines for the OLED display.
This project is a simple yet fun way to create a romantic quote generator using MicroPython and the XIAO ESP32C3. Ideal for gifts or a fun Valentine's Day project! 💖
Comments
Please log in or sign up to comment.