Eid greeting card on an Arduino Uno
A 16x2 LCD with a hand-drawn crescent and star says Eid Mubarak, and a button turns to the same wish in Arabic, Malay, Hausa and Somali while a lamp 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.
The code
The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.
// Eid greeting card: an LCD with a little crescent and star drawn on it
// that says Eid Mubarak, and a button that turns to the same wish in other
// languages Muslims around the world use.
//
// LCD 16x2 with an I2C backpack: SDA -> A4, SCL -> A5
// button pin 2 -> button -> GND (INPUT_PULLUP)
// lamp pin 5 -> 220 ohms -> yellow LED -> GND, a warm glow
//
// Eid Mubarak means "blessed Eid" in Arabic and is said everywhere. The card
// also has Eid Saeed (Arabic, "happy Eid"), Selamat Hari Raya (Malay and
// Indonesian, "happy day of celebration"), Barka da Sallah (Hausa, spoken in
// Nigeria and Niger) and Ciid Wanaagsan (Somali, "happy Eid").
//
// The crescent and the star are custom characters. A 16x2 LCD lets a sketch
// draw eight of its own, each 5 dots wide and 8 tall, one byte per row.
//
// Things to try. Press the button. Add your family's own greeting to
// GREETINGS: the wish, a second line if it is long, and the language.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int BUTTON_PIN = 2;
const int LAMP_PIN = 5;
LiquidCrystal_I2C lcd(0x27, 16, 2);
const uint8_t CRESCENT[8] = {0b00110, 0b01100, 0b11000, 0b11000, 0b11000, 0b01100, 0b00110, 0b00000};
const uint8_t STAR[8] = {0b00100, 0b00100, 0b11111, 0b01110, 0b01010, 0b10001, 0b00000, 0b00000};
// The wish, a second line if it needs one, and the language.
const char *GREETINGS[][3] = {
{"Eid Mubarak", "", "Arabic"},
{"Eid Saeed", "", "Arabic"},
{"Selamat Hari", "Raya", "Malay"},
{"Barka da Sallah", "", "Hausa"},
{"Ciid Wanaagsan", "", "Somali"},
};
const int COUNT = sizeof(GREETINGS) / sizeof(GREETINGS[0]);
int shown = 0;
void show(int n) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(GREETINGS[n][0]);
lcd.setCursor(0, 1);
lcd.print(GREETINGS[n][1][0] ? GREETINGS[n][1] : GREETINGS[n][2]);
lcd.setCursor(14, 1);
lcd.write(0); // the crescent
lcd.write(1); // the star
Serial.print(GREETINGS[n][0]);
if (GREETINGS[n][1][0]) {
Serial.print(" ");
Serial.print(GREETINGS[n][1]);
}
Serial.print(" (");
Serial.print(GREETINGS[n][2]);
Serial.println(")");
}
void setup() {
Serial.begin(9600);
pinMode(BUTTON_PIN, INPUT_PULLUP);
pinMode(LAMP_PIN, OUTPUT);
lcd.init();
lcd.backlight();
lcd.createChar(0, CRESCENT);
lcd.createChar(1, STAR);
analogWrite(LAMP_PIN, 120);
show(0);
}
void loop() {
if (digitalRead(BUTTON_PIN) == LOW) {
shown = (shown + 1) % COUNT;
show(shown);
while (digitalRead(BUTTON_PIN) == LOW) delay(10);
delay(50);
}
// A slow breathing glow on the lamp.
int t = (millis() / 8) % 512;
analogWrite(LAMP_PIN, 60 + (t < 256 ? t : 511 - t) / 2);
delay(10);
}
Parts list
6 parts, plus the jumper wires. Every one is in the editor's parts bin.
- 1 × Arduino Uno R3
- 1 × Half breadboard
- 1 × Pushbutton
- 1 × Resistor, 220 Ω
- 1 × LED, yellow
- 1 × Character LCD with I2C backpack
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, yellow 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, yellow 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.