Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

The Rat (Bluetooth Remote Controlled Car V0)

Demo

Description

This is my prototype for an RC Car named: The Rat.

board side right rear motor side left
board wide left front motor side right

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.

bottom

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
Stepper Motor Tutorial BlueTooth Controller Tutorial

Parts List

Main Components

ESP32 Devkit1 DOIT 28BYJ-48 Stepper Motor w/ ULN2003 Driver Board XBox One Controller
ESP32 Devkit1 DOIT 28BYJ-48 Stepper Motor w/ ULN2003 Driver Board XBox One Controller

Power Supply

AMS1117 Voltage Regulator 9V Battery 2x Capacitors
AMS1117 Voltage Regulator 9V Battery Capacitor

Car Parts

Wheels & Axles Gears
Wheels and Axles Gears

Wiring Diagram

Overall Wiring Diagram


Pinouts

ESP32 Devkit V1 - DOIT Pinout 28BYJ Stepper Motor Driver Pinout AMS1117 Voltage Regulator Pinout
ESP32 Pinout ULN2003 Stepper Motor Driver Board Pinout AMS1117 Voltage Regulator Pinout

Flow Diagram

Block Diagram

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++.

Pseudocode

#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:

Define/Initialize variables.

setup():

  • Serial.begin(115200): Initialize serial interface
  • stepperSetup(): 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 the throttle and brake values
  • dataUpdated: Check if the microcontroller's Bluetooth data has changed since last update
  • processControllers(): Process altered (dataUpdated?) inputs from controllers to update the throttle and brake values

Conclusions & Further Work

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.

About

Bluetooth Connected Remote Controlled Car using ESP32

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages