For this week’s assignment, I built a Smart Desk Motivator: a small gadget with an RGB mood light and an LCD that shows motivational quotes at the press of a button. The goal is to make studying or working at my desk more positive and enjoyable.
I chose this idea because I often lose focus during long hours at my desk, and a short uplifting message or a calming light effect can help reset my mindset. This makes the device both practical and fun.
My inspiration came from projects like Arduino Random with LCD and RGB LED Mood Light. I wanted to combine these ideas into something personal and useful for my daily routine.
Resources of Inspiration:
For this assignment, I used Tinkercad to design and simulate my circuit before physical implementation.
Tinkercad allows me to test the connections, components, and logic virtually, which helps in identifying errors early and saves time and materials before moving to real hardware.
Software/Machines/Materials Used
For this assignment, I used the Arduino IDE to write, compile, and upload the code that controls the smart safe system.
Why I Used It
The Arduino IDE provides an easy-to-use platform for coding in Arduino C, testing logic, and directly uploading programs to the Arduino UNO board. It also includes a built-in serial monitor that helps with debugging and verifying communication between components, which makes it ideal for developing and refining embedded system projects like this one.
LCD (16*2) with I2C
RGB LED
Resistor
Materials:
breadboard
Arduino UNO
Arduino Cable
Jumper wires
RGB LED
220 Ohm Resistor
LCD with I2C
Cardboard
Push Buttons
9V Power Adaptor
Buzzer
Ultrasonic Sensor
Breadboard, jumper wires, switch: for easy circuit assembly and testing.
9V power adaptor: to safely run all components.
Arduino Uno = brain
Buzzer – to generate sound (alerts/melody when the distance condition is met).
Resistors = protect/signal conditioning
Breadboard & Wires = connection platform
RGB LED: for lighting at night
Cardboard: for holding the mechanical part
LCD: for displaying the Quotes
Push Button: Dynamic Input for the LCD and RGB LED
Measures distance by sending ultrasonic pulses and receiving the echo.
Acts as a proximity detector (triggers buzzer when an object < 20 cm).
Dynamic Inputs:
2 Dynamic Push Buttons
Ultrasonic Sensor
Output (Action Components):
LCD to illustrate the random Quotes
RGB to show Red - Blue - Green sequence
Buzzer to make Music
Connected red, green, and blue pins of the RGB LED to Arduino pins 7, 6, and 5 through resistors 330 Ohm.
Common cathode connected to GND.
Added a push button on pin 4 using INPUT_PULLUP to toggle the RGB light on/off.
Programmed cycling of colors (red → blue → green) with if conditions and delay().
Used a 16x2 I2C LCD for easier wiring.
Connected SDA → D18 and SCL → D19, with VCC → 9V and GND → GND.
Added a button on pin 3 to toggle LCD quotes on/off.
Programmed the LCD with the LiquidCrystal_I2C library to display random quotes using the random() function.
Used an HC-SR04 ultrasonic sensor for non-contact distance measurement.
Connected Trig → pin 8 and Echo → pin 9, with VCC → 5V and GND → GND.
Programmed to calculate distance using pulseIn() and the sound speed formula.
Configured a threshold: if an object is closer than 20 cm, it triggers the buzzer melody.
Used a passive buzzer connected with positive → pin 10 and negative → GND.
Programmed with the Arduino tone() function to play a simple melody.
Activated only when the ultrasonic sensor detects an object within range.
Provides audible feedback to enhance the system's interactivity.
Designed and tested the circuit in Tinkercad Circuits before implementation.
Verified pin connections, button logic, buzzer, ultrasonic sensor and LCD text alignment.
This reduced wiring errors and made the physical build easier.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// RGB
const int RGB_Red = 7;
const int RGB_Blue = 6;
const int RGB_Green = 5;
// Buttons
const int RGB_Button = 4;
const int LCD_Button = 3;
// Ultrasonic + Buzzer
const int trigPin = 8;
const int echoPin = 9;
const int buzzer = 10;
//RGB Button
bool isOn = false;
bool lastRGBButtonState = HIGH;
//LCD
LiquidCrystal_I2C lcd(0x27, 16, 2);
bool lastLCDButtonState = HIGH;
bool lcdOn = false;
int quoteIndex = 0;
//Quotes
String quotes[] = {
"Keep moving!", "Believe in yourself", "Dream big.", "Stay positive!",
"Never give up.", "Enjoy your day", "Your blessings?", "Most imp Advice?",
"Love your family", "Commitment today?", "No perfectionism", "Start small now",
"Baby steps matter", "Be kind to yourself", "Your faults?", "Your day routine?",
"Grateful for today?", "What excites you?", "Let go of fears", "Smile at a stranger",
"Write 3 wins today", "What inspires you?", "Focus on progress", "What drains energy?",
"Define success now", "Write 1 big goal", "Who supports you?", "Acts of kindness?",
"Your core values?", "What to forgive?", "Step outside comfort", "Name 3 strengths",
"Your happy memory?", "Who to thank today?", "1 word for today?"
};
const int numQuotes = sizeof(quotes) / sizeof(quotes[0]);
// Simple melody (notes + durations)
int melody[] = {262, 294, 330, 349, 392, 440, 494, 523}; // C D E F G A B C
int noteDurations[] = {4, 4, 4, 4, 4, 4, 4, 4}; // quarter notes
long getDistance() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
return duration * 0.034 / 2; // cm
}
void playMelody() {
for (int i = 0; i < 8; i++) {
int noteDuration = 1000 / noteDurations[i];
tone(buzzer, melody[i], noteDuration);
delay(noteDuration * 1.3);
noTone(buzzer);
}
}
void setup()
{
pinMode(RGB_Red, OUTPUT);
pinMode(RGB_Green, OUTPUT);
pinMode(RGB_Blue, OUTPUT);
pinMode(RGB_Button, INPUT_PULLUP);
pinMode(LCD_Button, INPUT_PULLUP);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzer, OUTPUT);
randomSeed(analogRead(A0));
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Press button :)");
}
void loop()
{
//RGB Button
bool RGBbuttonState = digitalRead(RGB_Button);
if (lastRGBButtonState == HIGH && RGBbuttonState == LOW) {
isOn = !isOn;
delay(200);
}
lastRGBButtonState = RGBbuttonState;
//LCD Button
bool LCDbuttonState = digitalRead(LCD_Button);
if (lastLCDButtonState == HIGH && LCDbuttonState == LOW) {
lcdOn = !lcdOn;
if (lcdOn) {
quoteIndex = random(numQuotes);
lcd.clear();
String quote = quotes[quoteIndex];
if (quote.length() < 16){
lcd.setCursor(0, 0);
lcd.print("Hello my Girl,");
lcd.setCursor(0, 1);
lcd.print(quote.substring(0, min(16, quote.length())));
} else {
lcd.setCursor(0, 0);
lcd.print(quote.substring(0, 16));
lcd.setCursor(0, 1);
lcd.print(quote.substring(16, min(32, quote.length())));
}
} else {
lcd.clear();
lcd.print("LCD Off");
lcdOn = false;
}
delay(200);
}
lastLCDButtonState = LCDbuttonState;
// RGB Logic
if (isOn){
digitalWrite(RGB_Red, HIGH); delay(1000); digitalWrite(RGB_Red, LOW); if (!isOn) return;
digitalWrite(RGB_Blue, HIGH); delay(1000); digitalWrite(RGB_Blue, LOW); if (!isOn) return;
digitalWrite(RGB_Green, HIGH); delay(1000); digitalWrite(RGB_Green, LOW); if (!isOn) return;
} else {
digitalWrite(RGB_Red, LOW);
digitalWrite(RGB_Blue, LOW);
digitalWrite(RGB_Green, LOW);
}
// Ultrasonic + Buzzer
long distance = getDistance();
if (distance > 0 && distance < 20) { // threshold = 20cm
playMelody();
}
}
RGB LED
Red pin → Arduino pin 7 (through ~220Ω resistor).
Green pin → Arduino pin 5 (through resistor).
Blue pin → Arduino pin 6 (through resistor).
Common cathode → GND.
Button 1 (RGB control) → Arduino pin 4, other side → GND.
Button 2 (LCD control) → Arduino pin 3, other side → GND
Use Arduino’s INPUT_PULLUP → no external resistors needed.
VCC → Arduino 5V.
GND → Arduino GND.
SDA → Arduino D18(SDA).
SCL → Arduino D19 (SCL).
Positive terminal → Arduino pin 10.
Negative terminal → GND.
Used with tone() function to play melodies when an object is detected.
VCC → Arduino 5V.
GND → Arduino GND.
Trig Pin → Arduino pin 8.
Echo Pin → Arduino pin 9.
Measures distance by sending ultrasonic pulses and detecting their echo.
Power circuit via Arduino USB or external 9V adapter.
Ensure all grounds are connected together.
Upload the Arduino code.
On startup, LCD shows: “Press button :)”.
RGB Button → Cycles LED colors: Red → Blue → Green.
LCD Button → Randomly displays a motivational quote, or “LCD Off” when toggled.
Ultrasonic Sensor + Buzzer → When an object is detected within 20 cm, the buzzer plays a short melody.
RGB LED, LCD, and Ultrasonic+Buzzer operate independently, each controlled by their own logic.
The bug was that the first line started at index 16, skipping the first 16 characters of the quote. That meant nothing (or “random” characters) appeared, so the LCD didn’t show the expected text. I shared my code and asked why the LCD wasn’t showing quotes correctly.
-The key suggestion was that the substring should start at 0 for the first line, not 16.
-I built upon the suggestion to fix the substring indices, improving my LCD printing logic to split quotes into two lines properly.
- By sharing my detailed code, I contributed to the group’s understanding of how substring indexing works in Arduino and helped highlight a common mistake that others can avoid.
- They spotted the indexing mistake and explained why it caused the LCD to skip the first characters, providing a corrected version of the code.
The push button used had 4 legs.
I initially connected the two legs next to each other, which caused the button not to work.
Even though I set the pin mode as INPUT_PULLUP, the circuit didn’t respond correctly.
Solution
Discovered that the correct way was to connect the diagonal legs of the push button.
Removed the external resistor since INPUT_PULLUP already handles it internally.
After rewiring, the push button worked properly.
How I Found the Solution
Researched online tutorials and maker forums about push-button wiring.
Discovered the correct method is connecting the diagonal legs.
Learned that INPUT_PULLUP removes the need for an external resistor.
Rewired and tested the circuit → push button worked properly.
When the push button was clicked to turn off the RGB, the LED cycle didn’t stop.
The lights continued running even though the button was pressed.
This was not a wiring problem but a logic issue in the code.
Added the line if (!isOn) return; inside the RGB sequence.
This ensured that when the button is pressed again, the RGB loop stops immediately.
Now the LED responds correctly to the button state (ON/OFF).
This week, I learned how to connect and program an LCD with I2C and how to display random motivational quotes on it. This skill directly supports my final project because the random quote generator displayed on the LCD is a complete feature of the device. By mastering the wiring of the LCD and the logic behind generating and displaying random text, I can now integrate this function into my final prototype. It adds both interaction and motivation to the project, making it not only technically functional but also meaningful for users.
This week, aside from the main assignment, I started experimenting with Processing to learn how we can use it to create visuals for a game on the laptop. I also tried out the Simon Game, and after many attempts, I managed to score 9 points! Through this, I learned the importance of correctly connecting the Arduino UNO, paying attention to the ports, and then uploading the Processing code so that everything works together smoothly. It was a fun way to combine both hardware and software to bring an interactive game to life.