Desk Game Buddy

by 1005587 in Circuits > Arduino

31 Views, 1 Favorites, 0 Comments

Desk Game Buddy

IMG_8719 (1).jpg

The robot desk buddy is a small interactive partner that reacts to light, touch, and your presence. It uses sensors to detect changes in its environment and respond in real time. The push button allows the user to play a simple game where the goal is to avoid dangerous obstacles. Overall, the purpose of this project is to combine basic electronics with playful programming to demonstrate how simple components can be used to create something fun and engaging.

Supplies

download.jpg
download.jpg
download.jpg
images.jpg
download.jpg
images.jpg
download.jpg
Electrical-wirings-1024x434.jpg
O2xOAG5EYsGx9hWE-light-dependent-resistor.jpg
  1. Breadboard
  2. Push Button
  3. (2x) 10k Resistors
  4. potentiometer
  5. 160 Ohm resistor
  6. LCD 16x2 Backlit Display
  7. Light dependent resistor
  8. Wires
  9. Arduino Uno Rev3

(Optional) ThinkerCAD

Screenshot 2026-01-21 at 5.47.39 PM.png

Before building the circuit with real parts, you can practice using Tinkercad Circuits. Tinkercad lets you design and test Arduino circuits online, helping you check your wiring and code (which is given in this tutorial) without risk. This makes it easier to fix mistakes and understand how everything works before building the final project.

Getting Started

IMG_8718 (1).jpeg

First, I added a potentiometer to the breadboard. The potentiometer is used to control values in the circuit and helps adjust the input smoothly. I connected it to power, ground, and left the middle pin for later. Next, I added a push button to the breadboard. The push button allows the user to interact with the robot desk buddy. I connected one side of the button to a digital pin (3) on the Arduino and the other side to ground and power so it could detect presses correctly. Then, I added a light-dependent resistor (LDR). The LDR allows the robot to sense light levels. I connected it to A5 so the Arduino could read changes in light through an analog pin.

LDC

IMG_8717 (1).jpeg

After that, I added the LCD screen to the breadboard. The LCD is used to display facial expressions and to play the game. I carefully placed it so all the pins lined up correctly with the breadboard. Next, I finished wiring the LCD. I connected the RS, E, and data pins (D4–D7) to the correct digital pins on the Arduino. I also connected power and ground so the screen would display clearly.

Testing

After fixing the code, I tested the push button. The button now works correctly and responds when pressed. It successfully controls actions in the program. Then, I tested the LCD screen. The screen displays text and animations properly, including facial expressions. The contrast and wiring were confirmed to be working correctly.

Downloads

Final Product

IMG_8710.jpeg

Finally, the robot desk buddy was complete. It responds to light using the LDR, reacts to button presses, and displays expressions on the LCD. All components work together as intended.

Code

Screenshot 2026-01-21 at 10.25.51 PM.png
Screenshot 2026-01-21 at 10.26.04 PM.png
Screenshot 2026-01-21 at 10.26.41 PM.png
Screenshot 2026-01-21 at 10.26.53 PM.png
Screenshot 2026-01-21 at 10.27.08 PM.png
Screenshot 2026-01-21 at 10.27.19 PM.png
Screenshot 2026-01-21 at 10.27.33 PM.png

**copy-paste code**



#include <LiquidCrystal.h>


const int BUTTON = 7;

const int PR = A5;

const int GAME = 3;


const int RS = 8;

const int E = 9;

const int DB4 = 10;

const int DB5 = 11;

const int DB6 = 12;

const int DB7 = 13;


int prValue;

int buttonState;

int gameState;


int obsPos;

bool jumping;

unsigned long jumpTimer = 0;

unsigned long jumpDuration = 500;

int score;


LiquidCrystal lcd(RS, E, DB4, DB5, DB6, DB7);


void setup()

{

Serial.begin(9600);

pinMode(BUTTON, INPUT);

pinMode(GAME, INPUT);

pinMode(PR, INPUT);

lcd.begin(16, 2);

}


void loop()

{

prValue = analogRead(PR);


if(prValue < 932){

while(prValue < 932){

sleepMode();

}

}

else{

lcd.setCursor(6,0);

lcd.print("- -");

lcd.setCursor(7, 1);

lcd.print("O ");

delay(1000);

lcd.setCursor(6,0);

lcd.print("^ ^ ");

lcd.setCursor(7, 1);

lcd.print("-");

delay(1000);

lcd.setCursor(6,0);

lcd.print("^ ^");

lcd.setCursor(6, 1);

lcd.print("\\_/");

delay(1000);

lcd.setCursor(6,0);

lcd.print("^ ^");

lcd.setCursor(6, 1);

lcd.print("\\_/");


while (prValue > 932){

awakeMode();

}


lcd.setCursor(6,0);

lcd.print("- -");

lcd.setCursor(6, 1);

lcd.print("\\_/ ");

delay(1000);

lcd.setCursor(6,0);

lcd.print("- - ");

lcd.setCursor(6, 1);

lcd.print(" O ");

delay(1000);

lcd.setCursor(6,0);

lcd.print("- -");

lcd.setCursor(6, 1);

lcd.print(" o ");

delay(1000);

}

}


void awakeMode() {

buttonState = digitalRead(BUTTON);


// Normal happy face

lcd.setCursor(6,0);

lcd.print("^ ^ ");

lcd.setCursor(6,1);

lcd.print("\\_/ ");


// Check game button

gameState = digitalRead(GAME);

if (gameState == 1){

runGame();

}


prValue = analogRead(PR);

}


void sleepMode() {

lcd.setCursor(6,0);

lcd.print("- -");

lcd.setCursor(0, 1);

lcd.print(" ");

lcd.setCursor(7, 1);

lcd.print("- ");

delay(1000);

lcd.setCursor(6,0);

lcd.print("- -");

lcd.setCursor(7, 1);

lcd.print("o zZ");

lcd.setCursor(6,0);

lcd.print("- -");

delay(1000);

prValue = analogRead(PR);

}


void runGame() {

lcd.clear();


obsPos = 15;

jumping = false;

score = 0;


delay(500);

while (true) {

lcd.clear();

if (digitalRead(GAME) == HIGH && !jumping) {

jumping = true;

jumpTimer = millis();

}


if (jumping && millis() - jumpTimer > jumpDuration) {

jumping = false;

}


if (jumping) {

lcd.setCursor(2, 0);

lcd.print("O");

} else {

lcd.setCursor(2, 1);

lcd.print("O");

}


if (obsPos >= 0) {

lcd.setCursor(obsPos, 1);

lcd.print("/\\");

}


if (!jumping && obsPos == 2) {

lcd.clear();

lcd.setCursor(4, 0);

lcd.print("GAME OVER");

lcd.setCursor(4, 1);

lcd.print("Score: ");

lcd.print(score);

delay(2500);

lcd.clear();

lcd.setCursor(6,0);

lcd.print("^ ^ ");

lcd.setCursor(6, 1);

lcd.print("\\_/");

return;

}


obsPos--;

if (obsPos < -1) {

obsPos = 15;

score++;

}


delay(120);

}

}

Reflection/ Self-Improvement

While working on the Desk Game Buddy, I learned a lot about both coding and circuitry. At first, the project was confusing because some parts didn’t work the way I expected, especially the push buttons and the LCD. I had to recheck my wiring and fix my code multiple times before everything worked properly.

One of the hardest parts was debugging. Sometimes the code was uploaded, but the project still didn’t work, which was frustrating. Over time, I learned that breaking the code into smaller sections and testing each part helped a lot. I also learned how sensors like the potentiometer and light-dependent resistor can change how the project behaves in real time.

If I were to improve this project, I would make the desk buddy more interactive by adding more features or animations. Overall, this project helped me become more confident with Arduino, problem-solving, and documenting my work clearly.