Turning a cheap toy into your first Arduino robot

Kevin Yi
4 min readApr 6, 2021
Image from kmart.com.au

Start DIY robot as beginner with low budget.

Price

If you start your first Arduino robot project, a twin dc motor drived robot can be a good start , because it won’t cost your too much. Comparing with 12 DOF quadruped robot which normally costs you 1000$ , twin wheeler robot can be as less as under 30$.

Programming

When you think about robotics project you must heard of Arduino , that ‘s all because the Arduino IDE is really easy start for a robot program beginner. I personally never write any C code and know nothing about hardware, however with Arduino IDE and its plenty modular libraries and examples you can pick up things really quickly. I would also spend sometime on some projects with PlatformIO in future, but at this stage if you just want to get things start and work, Arduino IDE is your choice in my opinion.

simple and easy,good for beginner and non developer background user
PlatformIO IDE based on vscode, able to switch different develop framework including Arduino and espidf, however you need bit of software skill

MCU(MicroController)

You might think of buying a Arduino board to start with wiring and designing.

Arduino UNO , Full size and most components need to be plugged in (image from arduino.cc)

But in my case I chose to buy ESP32 board which is also compatible with Arduino IDE and many libraries. The reason for that is all because of its smaller size and features. It includes everything I needed for my project without buying and plugging many modules.

Image from docs.espressif.com

A ESP32 devkit board showing above includes wifi,bluetooth,USB-UART bridge and that just cost your around 5$ from aliexpress.

Hardware

Starting a robotics project will always cost you lots of time and money to figure out the hardware design including 3D printing parts , car chassis , motors and servos. You will also have to ensure assembling them all together without issue. I prefer to start some robot kit to begin with ,because it can easily control your overall budget. Instead of buying robot kit I am taking a slightly different approach, which is buying a cheap robot and modifying with my MCU. I managed to buy a 19$ robot with twin dc motors , quite nice body, battery holder and switch. so I can focus on programming and learning.

2 dc motors with wheels/old toy board/seaker ,RGB LED,mic can still be used

Parts and wiring

After some research I figured out the circuit wiring for remote controlled motor robot with my hardware.

Actual batter holder is 3 for 4.5v, all GPIO can be customised in code, when you flash code with USB ,don’t connect to battery
Power wiring
+----------+------------+-----------+
| Battery | ESP32 | tb6612fng |
+----------+------------+-----------+
| positive | VIN | VM |
| negative | GND | GND |
| | 3v3 | VCC |
+----------+------------+-----------+

Parts need to be purchased are:

ESP32 dev kit

TB6612fng motor driver

Sony PS3 controller (if you don’t have)

Code

You need to prepare two libraries for drive motors and pair with PS3 Bluetooth controller. Snippet code and small explanation are as below , you can always find source code and details in my github repo https://github.com/yikaus/kmart-at

# PS3 library for connect your ps3 bluetooth controller
#include <Ps3Controller.h>
# tb6612 motor driver
#include <TB6612FNG.h>
# configure motor GPIO is flexiable , just config it and pass to construct method of Tb6612fng// 5 - Standby pin
// 2 - AIN1 pin
// 4 - AIN2 pin
// 15 - PWMA pin
// 18 - BIN1 pin
// 19 - BIN2 pin
// 21 - PWMB pin
Tb6612fng motors(5, 4, 2, 15, 19, 18, 21);
...# initialise motor and ps3 controller void setup()
{
Serial.begin(115200);
Ps3.attach(notify);
Ps3.attachOnConnect(onConnect);
Ps3.begin();
motors.begin();

}

Demo

looks good

--

--