This is my prototype for an RC Car named: The Rat.
![]() |
![]() |
![]() |
|---|---|---|
![]() |
![]() |
![]() |
The car's axle uses gears to rotate with a 28BYJ-48 5V Stepper Motor and the ULN2003 motor driver which is controlled using an ESP32 Devkit V1 DOIT.
It was assembled by Estela Guzman. The body is built out of wood and extremities (u-bolts under the body securing the axles, microcontroller, motor and driver) are screwed/bolted on to secure it. The 9V is not tied down to change out easily.
The ESP32 triggers the motor using Arduino's Stepper.h library with an XBOX One remote controller that is connected through BlueTooth using Ricardo Quesada's Bluepad32.h.
This project largely uses the instructions provided in the following articles:
| Stepper Motor Control | BlueTooth Game Controller |
|---|---|
![]() |
![]() |
Main Components
| ESP32 Devkit1 DOIT | 28BYJ-48 Stepper Motor w/ ULN2003 Driver Board | XBox One Controller |
|---|---|---|
![]() |
![]() |
![]() |
Power Supply
| AMS1117 Voltage Regulator | 9V Battery | 2x Capacitors |
|---|---|---|
![]() |
![]() |
![]() |
Car Parts
| Wheels & Axles | Gears |
|---|---|
![]() |
![]() |
Pinouts
| ESP32 Devkit V1 - DOIT Pinout | 28BYJ Stepper Motor Driver Pinout | AMS1117 Voltage Regulator Pinout |
|---|---|---|
![]() |
![]() |
![]() |
While this is a simplified block diagram, it captures the necessary big picture aspects of the code. The pseudocode goes into some more detail in the style of C++.
#include <Stepper.h>
#include <Bluepad32.h>
const int stepsPerRevolution = 2048; // 32 steps with gear reduction of 64:1 -> 32*64=2048
const int stepSize = floor(stepsPerRevolution/360);
Stepper myStepper(stepsPerRevolution, D19, D5, D18, TX2);
int32_t throttle; // 0 -> 1023
int32_t brake; // 0 -> 1023
void setup() {
Serial.begin(115200);
stepperSetup();
bluetoothSetup();
}
void drive() {
if (throttle > 100) {
myStepper.step(stepSize);
}
if (brake > 100) {
myStepper.step(-stepSize);
}
if (!(throttle > 100 || brake > 100)) {
driveAllLow(IN1, IN2, IN3, IN4);
}
}
void loop() {
drive();
bool dataUpdated = BP32.update();
if (dataUpdated) processControllers();
}
Code Description
This code was written with the Arduino IDE and it uses both:
- The
Bluepad32.hlibrary - Arduino's
Stepper.hlibrary
Define/Initialize variables.
setup():
Serial.begin(115200): Initialize serial interfacestepperSetup(): Setup the stepper motor (set initial motor speed)bluetoothSetup(): Setup the microcontroller to properly connect and disconnect from BlueTooth Controllers
loop():
drive(): Drives based on thethrottleandbrakevaluesdataUpdated: Check if the microcontroller's Bluetooth data has changed since last updateprocessControllers(): Process altered (dataUpdated?) inputs from controllers to update thethrottleandbrakevalues
The Rat successfully drives using the Bluetooth connected XBox One controller powered by a 9V Battery.
I intend to get better wheels, axles, and gears.
My next iteration will incorporate tank controls (control left and right wheels with the left and right analog stick, respectively). This will require another motor and possibly an alternative power solution.






















