Community project

ESP32 Remote-Controlled Car

Photo of ESP32 Remote-Controlled Car
Generated with AI

Eduardo Fraga

Published December 5, 2026

Build a WiFi-controlled car powered by an ESP32 that responds to web-based commands from any browser. The car uses an L298N motor driver to control two TT DC gearmotors through simple directional logic, powered by four AA batteries for untethered operation.

This guide provides the complete wiring diagram, parts list, and Arduino firmware with an embedded web interface for forward, backward, left, and right movement. Assembly involves connecting the motor driver control pins to the ESP32, wiring the motors to the driver outputs, and testing with the wheels suspended before deployment.

Wiring diagram

Wiring diagram for ESP32 Remote-Controlled Car
Loading diagram…

Gather all the parts

QtyComponent
1

L298N dual H-bridge module (IN1–IN4)

Módulo para o carrinho TT

1

TT DC gearmotor with plastic gearbox

Módulo para o carrinho TT

1

TT DC gearmotor with plastic gearbox

Módulo para o carrinho TT

1

4xAA Battery Pack

Four alkaline AA cells in series, nominal 6 V, ~2500 mAh. Cheap non-rechargeable choice for portable Arduino Uno-style projects; feeds VIN through the on-board regulator.

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

1

Resistor

10 kΩ

Through-hole resistor (current-limiting in series with an LED)

Assemble it in 3 steps

1. Prepare o módulo com tudo desligado

Use o módulo com IN1 a IN4. Remova os jumpers ENA, ENB e 5V-EN. Neste circuito, o borne 5V recebe alimentação para a lógica; o borne marcado 12V recebe as quatro pilhas AA (6 V nominais).

  • Não ligue o borne 12V ao ESP32. Não use bateria retangular de 9 V.

2. Faça as ligações de controle

Ligue ENA e ENB aos GPIO25 e GPIO26. Cada um ganha seu próprio resistor de 10 kΩ até GND. Ligue IN1 a IN4 aos GPIO18, 19, 21 e 22. Una o GND do módulo ao GND do ESP32 e ao negativo das pilhas. Ligue o borne 5V ao VIN do DevKit alimentado por USB (confirme cerca de 5 V no VIN antes).

3. Monte e teste com as rodas suspensas

Fixe os motores no chassi. Ligue o esquerdo em OUT1/OUT2 e o direito em OUT3/OUT4. Se um girar ao contrário no comando Frente, desligue USB e pilhas e inverta só os dois fios desse motor.

Review all connections

1. Connections between "driver" and "ESP32"

FunctiondriverESP32
digitalENAGPIO 25
digitalENBGPIO 26
digitalIN1GPIO 18
digitalIN2GPIO 19
digitalIN3GPIO 21
digitalIN4GPIO 22
powerVS → 4xAA Battery Pack +6VEXT
groundGNDGND
power5VVIN

2. Connections between "ra" and "ESP32"

FunctionraESP32
digitalP1 → L298N dual H-bridge module (IN1–IN4) ENAEXT
groundP2GND

3. Connections between "rb" and "ESP32"

FunctionrbESP32
digitalP1 → L298N dual H-bridge module (IN1–IN4) ENBEXT
groundP2GND

4. Connections between "pack" and "ESP32"

FunctionpackESP32
groundGND → L298N dual H-bridge module (IN1–IN4) GNDEXT

5. Connections between "left" and "ESP32"

FunctionleftESP32
powerM1 → L298N dual H-bridge module (IN1–IN4) OUT1EXT
powerM2 → L298N dual H-bridge module (IN1–IN4) OUT2EXT

6. Connections between "right" and "ESP32"

FunctionrightESP32
powerM1 → L298N dual H-bridge module (IN1–IN4) OUT3EXT
powerM2 → L298N dual H-bridge module (IN1–IN4) OUT4EXT

Deploy the firmware

#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
WebServer server(80);
const int ea=25,eb=26,a=18,b=19,c=21,d=22;
unsigned long last=0;
char state='s';
void drive(char cmd){
  last=millis();
  if(cmd==state)return;
  digitalWrite(ea,LOW);digitalWrite(eb,LOW);
  digitalWrite(a,cmd=='f'||cmd=='r');digitalWrite(b,cmd=='b');
  digitalWrite(c,cmd=='f'||cmd=='l');digitalWrite(d,cmd=='b');
  digitalWrite(ea,cmd=='f'||cmd=='b'||cmd=='r');
  digitalWrite(eb,cmd=='f'||cmd=='b'||cmd=='l');
  state=cmd;
}
const char page[]=R"HTML(<!doctype html><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1"><style>body{text-align:center;font:24px sans-serif}button{padding:20px;margin:6px;touch-action:none}</style><h1>Carrinho</h1><p>Segure para mover. Solte para parar.</p><button data-c=f>Frente</button><br><button data-c=l>Esquerda</button><button data-c=s>Parar</button><button data-c=r>Direita</button><br><button data-c=b>Ré</button><script>
let timer,active=false,busy=false,cmd='s';
async function send(){if(busy)return;busy=true;const sent=cmd;try{await fetch('/move?c='+cmd,{method:'POST',signal:AbortSignal.timeout(300)})}catch(e){stop(false)}finally{busy=false;if(!active && cmd==='s' && sent!=='s')send() }}
function stop(notify=true){active=false;cmd='s';clearInterval(timer);if(notify)send()}
for(const b of document.querySelectorAll('button')){b.oncontextmenu=e=>e.preventDefault();b.onpointerdown=e=>{if(active||!e.isPrimary)return;e.preventDefault();b.setPointerCapture(e.pointerId);cmd=b.dataset.c;if(cmd==='s'){stop();return}active=true;send();timer=setInterval(send,120)};b.onpointerup=b.onpointercancel=b.onlostpointercapture=()=>stop()}
window.onblur=()=>stop();document.onvisibilitychange=()=>{if(document.hidden)stop()};</script>)HTML";
void setup(){
  for(int p:{ea,eb,a,b,c,d}){pinMode(p,OUTPUT);digitalWrite(p,LOW);}
  WiFi.mode(WIFI_AP);WiFi.softAP("Carrinho-TT","rodas2026",1,false,1);
  server.on("/",HTTP_GET,[]{server.send(200,"text/html; charset=utf-8",page);});
  server.on("/move",HTTP_POST,[]{String s=server.arg("c");char x=s.length()==1?s[0]:'s';if(x!='f'&&x!='b'&&x!='l'&&x!='r')x='s';drive(x);server.send(204);});
  server.begin();
}
void loop(){
  if(state!='s'&&(millis()-last>=450||!WiFi.softAPgetStationNum()))drive('s');
  server.handleClient();
}

Remix this project

Make it yours in one click

Open a full copy of this project in your own Schematik workspace, diagram, code, parts, and assembly steps included. Swap the sensor, add features, or redesign the whole thing with AI. The author's original stays untouched.

Open in Schematik