Desk Robot Buddy

by 802908 in Circuits > Arduino

14 Views, 1 Favorites, 0 Comments

Desk Robot Buddy

t725 (1).png
IMG_380C26F3-37FA-4BF1-A3ED-268127EC6077.jpeg

Have you ever wanted a small desk companion that reacts to you and its environment? In this project, I have made my very own Desk Buddy, an interactive device that uses sensors and outputs to respond to motion, light and different inputs. If you have prior computer engineering knowledge, you can also add different inputs and outputs.

Desk Buddy can:

1) Detect motion with PIR

2) React to light levels with LDR

3) Display messages on a LCD

4) Change colors using an RGB LED

5) Play sounds with a buzzer

6) Change into different modes based off user inputs


This is a simple, fun project that people of any level of computer engineering knowledge can make at the end result will make you stunned!

Supplies

image (1).png

Understanding How Desk Buddy Works + Schematic

image.png

Uptop is a schematic drawing of the circuit, for those who prefer to build the circuit using visuals.


Desk buddy operates via states:

Power ON -> Startup Mode -> Greeting

PIR Detects Motion -> Alert Mode -> LED Turns Red + Back Away Messages

Push Button Pressed -> Happy Mode -> Green LED + Friendly Message

No Motion -> Idle Mode -> Light-based behavior

Wiring the LCD

Screenshot 2026-01-22 103033.png
IMG_2215.jpeg

The IC2 LCD is a relatively easy component to use, its easier to connect, easier to use libraries with and overall makes the breadboard more clean. If you are a beginner, I suggest you use the I2C LCD as a must.

You may use a normal LCD, but keep in mind that it is more complex to connect, and the code on this tutorial will be assuming the LCD is a IC2 LCD so the libraries I use will not work for you. Instead, you need to use the Liquid crystal default library which you can find via: Sketch -> Include Libraries -> LiquidCrystal.

Wiring the I2C LCD only requires 4 pins while the normal one requires 10, and they both will function the same. The wiring is as follows:

When looking at your IC2 Backpack(flip your LCD) backwards, you will see the 4 pins, normally the order will go as follows: GND, VCC, SDA, SCL. If it is different, than wire it according to the order I state.

GND will go to the ground rail of the breadboard.

VCC will go to the power rail of the breadboard.

SDA will go to pin A4 on the Arduino.

SCL will go to pin A5 on the Arduino.


Simply connect 5V and GND to your breadboards allocated rows, and the LCD screen should turn on. Keep in mind that depending on the number it says on the back of your IC2 backpack, the screen may require 3.3V, simply search the number up and you will get the voltage you need.

Wiring the Sensors

Screenshot 2026-01-22 120526.png

Now, we can wire the PIR Sensor and LDR.

NOTE: The Tinkercad has the pins swapped, in reality, the output should be in middle, ground on left, and power on right.

Face the PIR's sphere like shape towards you, the order of the 3 pins should be as follows: GND, Output, VCC.

Connect GND to the ground rail of the breadboard.

Connect output to the D8 pin on your Arduino.

Connect VCC to the power rail of the breadboard.


The LDR doesn't have a specific orientation, just make sure both legs are on separate rows & columns on the breadboard. Connect one leg to the power rail (doesn't matter which one) and the other leg to the A1 pin on the Arduino through a 10k ohm resistor.

Wiring the Inputs & Outputs

Screenshot 2026-01-22 121118.png

The Buzzer is simple to wire. The buzzer should have a (+) side labeled and a (-) side labeled. Connect the (-) side to the ground rail and connect the (+) side to a digital pin on your Arduino, like number 7.

The pushbutton needs important wiring to work. The pin order doesn't matter, although make sure that one side has a resistor connecting to the ground rail, and other side has a wire connected to the power rail. For the top pins, make sure you put a wire connecting the opposite side of where you put to resistor to one of the digital pins on one of the Arduino pins (eg. 13).


The RGB Led is another major component that must be wired carefully. If you hold your RGB Led, you will notice that there are 4 pins. Orient the LED so that the longest pin is the second pin to the left, rather than the third. The pin before the long leg is going to be the Red Pin, the long leg can either be Common Anode(+) or Common Cathode (-) depending on what LED you bought. The next leg is the Green Leg and the fourth and final leg is the blue leg. A good way to remember this is that this is the RGB LED, so if you position it like that, the pins will follow the order of RGB with common anode/cathode as the second pin.

For each of the coloured pins, connect a current limiting resistor to each one (220-330 ohms) and leave one hole at the end to place wires that connect each coloured pin to a digital Arduino pin that supports Pulse With Modulation, the pin will have a tilde symbol ( ~ ), eg. pins 3, 5, 6, 9, 10, 11.



Code for Arduino

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


LiquidCrystal_I2C lcd(0x27, 16, 2);


const int potPin = A0;
const int ldrPin = A1;
const int pirPin = 8;
const int buttonPin = 7;


const int buzzerPin = 9;
const int redPin = 3;
const int greenPin = 5;
const int bluePin = 6;


int potValue;
int lightValue;
bool motionDetected;

void setup() {

pinMode(pirPin, INPUT);
pinMode(buttonPin, INPUT);


pinMode(buzzerPin, OUTPUT);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);


lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Robot Desk Buddy");
lcd.setCursor(0, 1);
lcd.print("Initializing...");
delay(1500);
lcd.clear();
}

void loop() {

potValue = analogRead(potPin);
lightValue = analogRead(ldrPin);
motionDetected = digitalRead(pirPin);

if (motionDetected) {
annoyedMode();
}
else if (digitalRead(buttonPin) == HIGH) {
happyMode();
}
else {
sleepMode();
}
}



void annoyedMode() {
setColor(255, 0, 0); // Red
lcd.setCursor(0, 0);
lcd.print("Too Close! ");
lcd.setCursor(0, 1);
lcd.print("Give me space ");

int sound = map(potValue, 0, 1023, 400, 1200);
tone(buzzerPin, sound, 300);
delay(400);
}

void happyMode() {
setColor(0, 255, 0);
lcd.setCursor(0, 0);
lcd.print("Hello! :) ");
lcd.setCursor(0, 1);
lcd.print("Nice to see u ");

tone(buzzerPin, 900, 200);
delay(300);
}

void sleepMode() {
setColor(0, 0, 60);
lcd.setCursor(0, 0);
lcd.print("Quiet... ");
lcd.setCursor(0, 1);
lcd.print("Zzz... ");
delay(500);
}


void setColor(int r, int g, int b) {
analogWrite(redPin, r);
analogWrite(greenPin, g);
analogWrite(bluePin, b);
}

Test

Download Arduino IDE and LiquidCrystal_IC2 Library if you have not. Link is in supplies.

With the Zip Library File, go to your Arduino Project -> Sketch -> Include Library -> Add ZIP Library and find the downloaded ZIP file from the link.

The Wire_h library should be a default library which you can find in the default libraries (Sketch -> Include Libraries, find wire_h somewhere in the dropdown).


Copy the code above, although if you decided to use different pin numbers to the ones I have used, than you must change that in the code to (const int buzzerPin = *whatever pin # you have attached the buzzer too*).

Upload the code, and you should have a working product,

Wait ~15 seconds for PIR warm-up

Move in front of the sensor -> Alert Mode

Press the button -> Happy Mode

Cover the LDR -> Sleep Mode

Although if you get any errors or bugs, refer to step #7.

Troubleshooting

Blank LCD? Make sure SDA is connected to A4 and SCL is A5, not the other way around. If the issue persists, screw the blue backpack screw on the back of the IC2 in a clockwise momentum until text shows.

Buzzer always on? Make sure nothing is blocking the PIR sensor.

No LED Colour? Make sure that the resistors are connected properly in front of the coloured legs, and make sure that depending on if your second pin is common anode (connect to power) or common cathode(connect to ground) is connected in the right area.

Button not working? Ensure resistor is properly connected and button is receiving power.

Final Product Video