ESP32 PS3 controller Bluetooth Car

 PARTS YOU NEED

  • ESP32 dev board
  • PS3 Controller (Sixaxis/DualShock 3)
  • Motor driver (L298N)
  • 2 DC motors (or RC car chassis with motors)
  • Battery pack for motors (6–12V depending on motors)
  • USB power or 5V regulator for ESP32
  • Jumper wires
  • Breadboard or direct soldering
  • Screwdriver (if using terminals)

 STEP 1: MOUNT THE HARDWARE

Option A: Car chassis already built
  • Most RC chassis have space on top. Place the ESP32 and driver board on the top plate.
  • Use double-sided tape, Velcro, or screws.
Option B: Bare motors + wheels
  • Fix motors to a simple chassis (wood, acrylic, 3D print, etc.).
  • Add wheels to the motor shafts.
  • Add a small front caster wheel if needed.
 STEP 2: POWER SETUP
ESP32:
  • Power via USB power bank
  • Or use 5V input pin (from LiPo + 5V regulator)
Motor Driver:
  • Use a separate battery pack (example: 7.4V LiPo or 6xAA)
  • Connect + to motor driver VIN / VM
  • Connect – to motor driver GND
IMPORTANT:
  • Connect ESP32 GND to motor driver GND
    Common ground is mandatory
 STEP 3: WIRE MOTORS TO DRIVER (L298N)
  • Motor A → OUT1 & OUT2
  • Motor B → OUT3 & OUT4
  • Remove 5V jumper if using external power above 7V
 STEP 4: WIRE ESP32 TO DRIVER (CONTROL PINS)
Example GPIO mapping:
ESP32 GPIO
L298N Pin
GPIO 5
IN1
GPIO 18
IN2
GPIO 19
IN3
GPIO 21
IN4
5V
5V logic
GND
GND
If your driver has ENA/ENB pins:
  • Jumper them HIGH
  • Or connect to PWM pins on ESP32 for speed control
 STEP 5: PAIR THE PS3 CONTROLLER
  1. Get ESP32 Bluetooth MAC
  2. Use Sixaxis Pair Tool and set that MAC to the controller
  3. Upload code that prints this:
#include <Ps3Controller.h>
void setup()
{
    Serial.begin(115200);
    Ps3.begin();
    String address = Ps3.getAddress();
    Serial.print(“The ESP32’s Bluetooth MAC address is: “);
    Serial.println(address);
}
void loop()
{
}
  1. Press PS button to connect
 STEP 6: UPLOAD THE CAR CODE
Copy this into Arduino IDE:
#include <Ps3Controller.h>
//Right motor
int enableRightMotor=22; 
int rightMotorPin1=16;
int rightMotorPin2=17;
//Left motor
int enableLeftMotor=23;
int leftMotorPin1=18;
int leftMotorPin2=19;
const int PWMFreq = 1000; /* 1 KHz */
const int PWMResolution = 8;
const int rightMotorPWMSpeedChannel = 4;
const int leftMotorPWMSpeedChannel = 5;
void notify()
{
  int yAxisValue =(Ps3.data.analog.stick.ly);  //Left stick  – y axis – forward/backward car movement
  int xAxisValue =(Ps3.data.analog.stick.rx);  //Right stick – x axis – left/right car movement
  int throttle = map( yAxisValue, 127, -127, -255, 255);
  int steering = map( xAxisValue, -127, 127, -255, 255);  
  int motorDirection = 1;
  if (throttle < 0)       //Move car backward
  {
    motorDirection = -1;    
  }
  int rightMotorSpeed, leftMotorSpeed;
  rightMotorSpeed =  abs(throttle) – steering;
  leftMotorSpeed =  abs(throttle) + steering;
  rightMotorSpeed = constrain(rightMotorSpeed, 0, 255);
  leftMotorSpeed = constrain(leftMotorSpeed, 0, 255);
  //Serial.println(rightMotorSpeed);
  //Serial.println(leftMotorSpeed);  
  rotateMotor(rightMotorSpeed * motorDirection, leftMotorSpeed * motorDirection);
}
void onConnect()
{
  Serial.println(“Connected!.”);
}
void onDisConnect()
{
  rotateMotor(0, 0);
  Serial.println(“Disconnected!.”);    
}
void rotateMotor(int rightMotorSpeed, int leftMotorSpeed)
{
  if (rightMotorSpeed < 0)
  {
    digitalWrite(rightMotorPin1,LOW);
    digitalWrite(rightMotorPin2,HIGH);    
  }
  else if (rightMotorSpeed > 0)
  {
    digitalWrite(rightMotorPin1,HIGH);
    digitalWrite(rightMotorPin2,LOW);      
  }
  else
  {
    digitalWrite(rightMotorPin1,LOW);
    digitalWrite(rightMotorPin2,LOW);      
  }
  if (leftMotorSpeed < 0)
  {
    digitalWrite(leftMotorPin1,LOW);
    digitalWrite(leftMotorPin2,HIGH);    
  }
  else if (leftMotorSpeed > 0)
  {
    digitalWrite(leftMotorPin1,HIGH);
    digitalWrite(leftMotorPin2,LOW);      
  }
  else
  {
    digitalWrite(leftMotorPin1,LOW);
    digitalWrite(leftMotorPin2,LOW);      
  } 
  ledcWrite(rightMotorPWMSpeedChannel, abs(rightMotorSpeed));
  ledcWrite(leftMotorPWMSpeedChannel, abs(leftMotorSpeed));   
}
void setUpPinModes()
{
  pinMode(enableRightMotor,OUTPUT);
  pinMode(rightMotorPin1,OUTPUT);
  pinMode(rightMotorPin2,OUTPUT);
  pinMode(enableLeftMotor,OUTPUT);
  pinMode(leftMotorPin1,OUTPUT);
  pinMode(leftMotorPin2,OUTPUT);
  //Set up PWM for motor speed
  ledcSetup(rightMotorPWMSpeedChannel, PWMFreq, PWMResolution);
  ledcSetup(leftMotorPWMSpeedChannel, PWMFreq, PWMResolution);  
  ledcAttachPin(enableRightMotor, rightMotorPWMSpeedChannel);
  ledcAttachPin(enableLeftMotor, leftMotorPWMSpeedChannel);  
  rotateMotor(0, 0);
}
void setup()
{
  setUpPinModes();
  Serial.begin(115200);
  Ps3.attach(notify);
  Ps3.attachOnConnect(onConnect);
  Ps3.attachOnDisconnect(onDisConnect);
  Ps3.begin();
  Serial.println(“Ready.”);
}
void loop()
{
}

 ADD UPGRADES TO YOUR CAR

Don’t stop here you can add extra features like:
  • Camera (ESP32-CAM or FPV)
  • LEDs or indicators
  • Battery voltage display
  • WiFi or dashboard control
• • Sensors (ultrasonic, IR, line-following)
 
Skip to content