Desk toy
This week assignment is about building a gadget that stays on our desk and brings joy to my workspace so i came up with a device that whenever i get approached to the desk, recognises me and welcomes me with waving hands and a smile,while playing special sound.
Components
Arduino uno with USB cable for coding and programming
5V buzzer for playing music
breadboard to ease the connection
jumber wires to connect between components
Ultrasonic sensor for detecting an object froma distance
switch for manual/auto mode
led for indicating an object is detected
16*2 LCD screen for information display
Servomotor for controling the waving welcoming toy
220ohm resistance
Software
Tinkercad to design the device circuit and arduino for coding
The system combines an ultrasonic sensor, pushbuttons, an LCD display, a buzzer, LEDs, and a servo motor. It works in two modes:
Manual Mode : The ultrasonic sensor detects how close your hand is. If it’s within a threshold distance, the buzzer plays a tone, the LED lights up, and the servo swings a cardboard “baton.”
Auto Mode : The system ignores hand gestures and instead plays a preset melody while the servo swings in sync.
The current mode and sensor readings are shown on 16x2 LCD display.
Ultrasonic sensor detects hand distance.
Pushbutton 1 activates Manual Mode.
Pushbutton 2 activates Auto Mode.
Outputs
Buzzer plays tones or melodies.
LED lights up to indicate activity.
Servo motor moves the toy.
LCD screen displays active mode and distance
Two dynamic variables: distance (from ultrasonic) and mode State (from button input).
If conditions:
if (distance < 10) in manual mode then trigger sound, LED, and servo.
Logical branching / nested if:
Distinguish between Manual and Auto modes using pushbuttons.
Inserting breadboard
Inserting arduino
Inserting 5v buzzer
Adding the ultrasonic sensor
Connecting the components to arduino using jumbers
preparation and connection of circuit and adding LCD to the circuit by connecting vcc to 5V of arduino and gnd to ground.SDA to SDA of arduino and SCL to SCL of arduino data pin
writing the code in arduino software
If conditions:
if (distance < 10) in manual mode then trigger sound, LED, and servo.
Logical branching / nested if:
Distinguish between Manual and Auto modes using pushbuttons.
picture of DESK TOY
Video showing the magic
video showing final circuit
One challenge i faced was switching between Manual and Auto modes using switches. At first, a single press sometimes caused the system to flicker between modes or misread the input, because of button bouncing and the way the Arduino loop checks inputs. To solve i made a research on internet and used separate switches for each mode (one for Manual, one for Auto) and added a short software debounce delay after reading the button state. This made the mode switching stable and predictable, so the user can easily choose the desired mode without errors.
The coolest thing from this week was the end of week session when we had to make in groups ,a smart planter.
Arduino code