Desk Robot Buddy
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
Breadboard (preferably not mini or small)
10 Kiloohm Resistor (3x)
330 ohm resistor (3x)
Wires (25x)
Software:
Understanding How Desk Buddy Works + Schematic
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
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
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
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
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.