Built-in project · Arduino Uno R3

Message display gift on an Arduino Uno

A 16x2 LCD gift full of your own notes for Mother’s Day, Father’s Day or anyone who looks after you: a button turns to the next one and a red LED heart glows. The whole build, an Arduino Uno and 4 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Beginner Runs in your browser. Free, and no account needed.

Message display gift · Arduino Uno R3live0.000 s 0.00x
Press the button for the next message
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Arduino Uno R3
// Message display gift: a little screen for Mother's Day, Father's Day or a
// birthday, full of notes you wrote yourself. Press the button for the next
// one, and a heart glows on every new message.
//
//   LCD       16x2 with an I2C backpack: SDA -> A4, SCL -> A5
//   button    pin 2 -> button -> GND        (INPUT_PULLUP)
//   heart     pin 5 -> 220 ohms -> red LED -> GND
//
// The whole gift is the list in MESSAGES: two lines of up to 16 letters each.
// Write as many as you like, for a mom, a dad, a grandparent, a stepparent or
// anyone who looks after you, with their name in it. The first message
// shows at power-up, and after the last one it starts again.
//
// The heart on the LCD is a custom character, eight rows of five dots. When
// nobody has pressed the button for a while, the screen moves on by itself,
// so the gift keeps talking on a shelf.
//
// Things to try. Press the button. Write your own MESSAGES, with a name.
// Set AUTO_MS to 0 to make it wait for the button.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

const int BUTTON_PIN = 2;
const int HEART_PIN = 5;
const unsigned long AUTO_MS = 20000UL;

LiquidCrystal_I2C lcd(0x27, 16, 2);

const uint8_t HEART[8] = {0b00000, 0b01010, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000, 0b00000};

const char *MESSAGES[][2] = {
  {"Happy Mother's", "Day!"},
  {"Thank you for", "everything"},
  {"You make every", "day better"},
  {"Best hugs in", "the world"},
  {"I love you", "to the moon"},
  {"Love always,", "for you, Mom"},
};
const int COUNT = sizeof(MESSAGES) / sizeof(MESSAGES[0]);

int shown = 0;
unsigned long shownAt = 0;

void show(int n) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(MESSAGES[n][0]);
  lcd.setCursor(0, 1);
  lcd.print(MESSAGES[n][1]);
  lcd.setCursor(15, 1);
  lcd.write(0);
  shownAt = millis();
  Serial.print("Message ");
  Serial.print(n + 1);
  Serial.print(": ");
  Serial.print(MESSAGES[n][0]);
  Serial.print(" ");
  Serial.println(MESSAGES[n][1]);
  // The heart glows up and fades.
  for (int v = 0; v < 256; v += 8) {
    analogWrite(HEART_PIN, v);
    delay(8);
  }
  for (int v = 255; v >= 0; v -= 4) {
    analogWrite(HEART_PIN, v);
    delay(8);
  }
}

void setup() {
  Serial.begin(9600);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(HEART_PIN, OUTPUT);
  lcd.init();
  lcd.backlight();
  lcd.createChar(0, HEART);
  show(0);
}

void loop() {
  bool pressed = digitalRead(BUTTON_PIN) == LOW;
  bool timeUp = AUTO_MS > 0 && millis() - shownAt >= AUTO_MS;
  if (pressed || timeUp) {
    shown = (shown + 1) % COUNT;
    show(shown);
    while (digitalRead(BUTTON_PIN) == LOW) delay(10);
  }
  delay(10);
}

Parts list

6 parts, plus the jumper wires. Every one is in the editor's parts bin.

How it is wired

7 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Arduino Uno R3 pin 5; Resistor, 220 Ω pin 1
  • Arduino Uno R3 pin 2; Pushbutton pin 1a
  • Arduino Uno R3 pin 5V; Character LCD with I2C backpack pin VCC
  • Ground: Arduino Uno R3 pin GND; Pushbutton pin 2a; LED, red pin C; Character LCD with I2C backpack pin GND
  • Arduino Uno R3 pin A4; Character LCD with I2C backpack pin SDA
  • Arduino Uno R3 pin A5; Character LCD with I2C backpack pin SCL
  • Resistor, 220 Ω pin 2; LED, red pin A

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.