Introduction: Build Your Own Desktop Pet Robot With Arduino
Hey, fellow robotics enthusiasts! Get ready to dive into the exciting world of building your very own robot companion, and we're naming it "YAKSHA."
YAKSHA's going to be our Cozmo-inspired robotic buddy, and it's going to have its own unique charm and personality.
In this guide, we'll explore the art of creating a desktop-sized robot with YAKSHA, who's all set to become your new best friend. To make it all happen, we're going to use the Arduino Nano as the brain behind YAKSHA, allowing us to shape its character, movements, and interactions in a way that's uniquely YAKSHA.
As we tackle this project, we'll not only build a robot but also gain a deeper understanding of robotics, and programming. This is your opportunity to expand your skills in electronics and coding while breathing life into your one-of-a-kind robotic companion, YAKSHA.
So, go grab your gear, set up your workspace, and let's embark on this thrilling adventure to create YAKSHA, with a character that's going to make it the star of the show. Ready to bring YAKSHA to life and make a new friend? Let's dive in!
Attachments
Supplies
Supplies required
Electronics:
- 2 x Arduino Nano
- OLED Display
- DRV8833 Motor Driver
- 7.4V LiPo Battery
- Connecting Wires
- Breadboard
- Perforated Prototyping Board
- 4 x N20 Motors
- N20 Motor Wheels
- Servo Motor
- HC-05 Bluetooth Module
- Male Header Pins
- Female Header Pins
Hardware:
- 5mm Sunboard for Chassis
- Thick Sheet for Canopy
- Tiny Screws
Tools:
- Soldering Iron
- Solder Paste
- Hot Glue Gun
- Super Glue
- Cutting Hobby Knife
- Screwdriver
- Wrench Set
- Wire Stripper and Cutter
- Computer with the Arduino IDE Installed
Step 1: Assembling the Chassis
To start building the chassis for your robot, you'll need a base plate made from a 5mm Sunboard with dimensions 90mm x 45mm (length x width). This base plate serves as the foundation for your robot's structure.
To assemble the chassis, follow these steps:
- Begin by placing the 90mm x 45mm Sunboard base plate on your workspace.
- Attach the single vertical member to the base plate. The drawing below illustrates the positioning and dimensions of this vertical member.
- Assemble the horizontal midplate onto the chassis structure.
- Assemble the sunboard pieces with the help of Super glue.
- After this step the basic chassis is completed.
Attachments
Step 2: Assemble the Prime Movers ( N20 Motors)
To assemble the N20 motors, follow these steps gather the following materials:
- 4 x N20 Motors
- Super glue
- Identify the location on your chassis where the motors will be attached. Typically, you'll have one motor for each wheel. Refer to your chassis design for the specific placement.
- Use super glue or a suitable adhesive to securely attach the N20 motors to the chassis. Make sure they are properly aligned and firmly adhered to prevent any wobbling or movement during operation. It might seem a bit odd to use super glue for motors, but I found it to work well for my setup. If you prefer, you can use suitable fasteners, but for the sake of simplicity, I'm using super glue here.
- After attaching the motors, slide the N20 motor wheels onto the motor shafts. These wheels will be responsible for providing traction and enabling your robot to move.
- Repeat this process for all four N20 motors, ensuring that each one is correctly attached to the chassis and has its wheel securely glued in place.
- Once all the motors and wheels are in place, your robot's prime movers are ready, and it's one step closer to mobility.
Step 3: Assembling the ELECTRONICS
In this step, you'll assemble the electronic components that breathe life into your robot. You'll connect the Arduino Nano boards, motor driver, Oled Display, servo motor etc
please refer to the provided circuit diagram
- Connect Electronics: Follow the circuit diagram to connect all the electronic components. Ensure that the connections match the diagram accurately.
- Double-Check: Before proceeding, double-check all connections to ensure they align with the circuit diagram.
- Completing the Assembly: With the electronics properly connected according to the circuit diagram, your robot is now equipped with the necessary control systems to perform its tasks.
Step 4: Why Two Arduino Nanos?
Why Two Arduino Nanos?
You might be wondering why we're using two Arduino Nano boards. Here's the deal: one Nano will take the wheel—literally—and drive the motors and control the servo arm for precise movement. Meanwhile, the other Nano will be in charge of managing the OLED display to create expressive 'eyes' that add character to our robot.
Using a single Arduino for both tasks is possible, but I tried it and encountered a few challenges that I couldn't quite pinpoint. So, for the sake of efficiency and functionality, we've opted for two Nanos, each with a dedicated role.
Now, about that ESP32 WROOM 32 development board—it's a promising all-in-one solution, and I'll definitely be exploring it in the future. But for now, let's get back to building with our two trusty Arduino Nano boards.
Step 5: Arduino Programming
#include <Servo.h>
int outPin1 = 5; //motor1
int outPin2 = 6; //motor1
int outPin4 = 9; //motor2
int outPin3 = 10; //motor2
int pos = 0;
int enable = 2; //motor2
Servo myservo;
int analogValue = 0;
char bt;
void setup()
{
Serial.begin(9600);
myservo.attach(12);
pinMode(outPin1, OUTPUT);
pinMode(outPin2, OUTPUT);
pinMode(outPin3, OUTPUT);
pinMode(outPin4, OUTPUT);
pinMode(enable, OUTPUT);
}
void loop()
{
if (Serial.available() > 0)
{
bt = Serial.read();
digitalWrite(enable, 1);
if (bt == '0')
{
analogValue = 0;
}
if (bt == '1')
{
analogValue = 25;
}
if (bt == '2')
{
analogValue = 50;
}
if (bt == '3')
{
analogValue = 75;
}
if (bt == '4')
{
analogValue = 100;
}
if (bt == '5')
{
analogValue = 125;
}
if (bt == '6')
{
analogValue = 150;
}
if (bt == '7')
{
analogValue = 175;
}
if (bt == '8')
{
analogValue = 200;
}
if (bt == '9')
{
analogValue = 225;
}
if (bt == 'q')
{
analogValue = 255;
}
if (bt == 'F') //move forwards
{
analogWrite(outPin1, analogValue);
analogWrite(outPin2, 0);
analogWrite(outPin3, analogValue);
analogWrite(outPin4, 0);
}
if (bt == 'B') //move backwards
{
analogWrite(outPin1, 0);
analogWrite(outPin2, analogValue);
analogWrite(outPin3, 0);
analogWrite(outPin4, analogValue);
}
if (bt == 'S') //stop!!
{
analogWrite(outPin1, 0);
analogWrite(outPin2, 0);
analogWrite(outPin3, 0);
analogWrite(outPin4, 0);
}
if (bt == 'R') //right
{
analogWrite(outPin1, analogValue);
analogWrite(outPin2, 0);
analogWrite(outPin3, 0);
analogWrite(outPin4, analogValue);
}
if (bt == 'L') //left
{
analogWrite(outPin1, 0);
analogWrite(outPin2, analogValue);
analogWrite(outPin3, analogValue);
analogWrite(outPin4, 0);
}
if (bt == 'I') //forward right
{
analogWrite(outPin1, analogValue);
analogWrite(outPin2, 0);
analogWrite(outPin3, 0);
analogWrite(outPin4, analogValue);
}
if (bt == 'G') //forward left
{
analogWrite(outPin1, 0);
analogWrite(outPin2, analogValue);
analogWrite(outPin3, analogValue);
analogWrite(outPin4, 0);
}
if (bt == 'I') //right
{
analogWrite(outPin1, analogValue);
analogWrite(outPin2, 0);
analogWrite(outPin3, 0);
analogWrite(outPin4, 0);
}
if (bt == 'G') //left
{
analogWrite(outPin1, 0);
analogWrite(outPin2, 0);
analogWrite(outPin3, analogValue);
analogWrite(outPin4, 0);
}
if (bt == 'H') //right
{
analogWrite(outPin1, 0);
analogWrite(outPin2, analogValue);
analogWrite(outPin3, 0);
analogWrite(outPin4, 0);
}
if (bt == 'J') //left
{
analogWrite(outPin1, 0);
analogWrite(outPin2, 0);
analogWrite(outPin3, 0);
analogWrite(outPin4, analogValue);
}
if (bt == 'W')
{
for (pos = 180; pos >= 0; pos -= 1) {
myservo.write(pos);
delay(15);
}
}
if (bt == 'w')
{
for (pos = 0; pos <= 180; pos += 1) {
myservo.write(pos);
delay(15);
}
}
}
}
Step 6: Code for Eyes
Get code for eyes from the link and upload in the Arduino nano for eyes.
Step 7: Controlling Your Robot
Controlling Your Robot with the Bluetooth RC Car App
In this step, we'll explore how to control your robot using the "Bluetooth RC Car" app by ANDI.co, which will bring your robot to life and allow you to command it effortlessly.
Materials Needed:
- Mobile device (smartphone or tablet)
- HC-05 Bluetooth module
- Pre-installed Arduino code on your robot (from Step 5)
Instructions:
- Prepare Your Mobile Device:
- Ensure your mobile device has Bluetooth capabilities.
- Go to your device's settings and enable Bluetooth.
- Install the "Bluetooth RC Car" App:
- Visit your device's app store and search for the "Bluetooth RC Car" app by ANDI.co.
- Download and install the app on your mobile device.
- Connect to the HC-05 Module:
- Turn on your robot and ensure the HC-05 module is powered.
- On your mobile device, open the Bluetooth settings and scan for available devices.
- You should see your HC-05 module listed. Pair with it by tapping on it and entering the default PIN (often 1234 or 0000).
- Open the "Bluetooth RC Car" App:
- Launch the "Bluetooth RC Car" app on your mobile device.
- Control Your Robot:
- The app provides a user-friendly interface with controls for movement. This often includes directional buttons, a joystick, or tilt-based controls.
- Use the app's controls to make your robot move in different directions, stop, and perform various tasks.
Step 8: Future Possibilities and Scope
In this final step, let's explore future possibilities for enhancing your robot's capabilities:
- Sensor Integration:
- Enhance your robot's awareness by adding sensors such as ultrasonic distance sensors, line-following sensors, or cameras. This opens the door for interactive responses to its environment.
- Advanced Control with ESP32:
- Elevate your robot's control capabilities by integrating the ESP32 development board. This enables advanced wireless control over Wi-Fi, providing a broader range of functionalities and the potential for remote operations.
- With these steps, you'll propel your robot into new realms of functionality, making it a versatile and intelligent companion. The integration of the ESP32 for advanced control over Wi-Fi will open up exciting possibilities for remote operations and expanded functionalities.