Robotics for Beginners: Learn ESP32 PlatformIO with VS Code | Blink LED Tutorial

The “I Built My First Robot” Moment | ESP32 Platformio with VS Code for blink led
I still remember the first time I made an LED blink.
It wasn’t the LED that excited me. It was the realization that I told a piece of hardware what to do, and it listened.
No magic. No mystery. Just code, a microcontroller, and a tiny light.
That moment changed everything. It was the first step toward RC cars, soccer bots, security cameras, and eventually a full robotics channel.
And today? That moment is yours.
Welcome to the Roborear Robotics Course. This is Episode 1. And by the end of this tutorial, you will have:
✅ A professional coding environment (VS Code + PlatformIO)
✅ Your first C++ program running on an ESP32
✅ A blinking LED (the “Hello World” of hardware)
✅ The foundation for every robotics project after this
Why ESP32? (And Why Not Arduino Uno?)
Let me be honest. The Arduino Uno is a great board. It’s simple, it’s everywhere, and it’s perfect for learning.
But for real robotics? The ESP32 is simply better.
| Feature | Arduino Uno | ESP32 |
|---|---|---|
| Processor Speed | 16 MHz | 160-240 MHz |
| RAM | 2 KB | 520 KB |
| Flash Storage | 32 KB | 4-16 MB |
| Built-in WiFi | ❌ No | ✅ Yes |
| Built-in Bluetooth | ❌ No | ✅ Yes |
| Number of Pins | 20 | 25+ |
| Price | ~$20-25 | ~$5-7 |
| Best For | Simple projects, learning basics | Robotics, IoT, complex projects |
For a BUET mechanical engineering student building soccer bots? The ESP32 is the obvious choice.
In this course, we’ll use the ESP32 for everything:
RC cars (wireless control)
Obstacle avoidance robots (sensors + motors)
Line followers (speed + precision)
Smart home devices (WiFi + Bluetooth)
But first? We blink an LED.
Check out my detailed review of the ESP32-C3 Super Mini -> The ESP32-C3 Super Mini: This Tiny Board Stole My Heart (And Yes, It Has WiFi)
What You’ll Need (Under $10!)
| Component | Specs | Approx Price (USD) |
|---|---|---|
| ESP32 Development Board | Any version (30-pin or 38-pin) | $5.00 – $7.00 |
| USB Cable (Data Cable!) | USB-A to Micro-USB or USB-C | $2.00 – $4.00 |
| LED (Optional external) | 5mm, any color | $0.10 – $0.20 |
| 220Ω Resistor (Optional) | For external LED | $0.02 – $0.05 |
| Breadboard (Optional) | 400 points | $0.85 – $1.25 |
| Jumper Wires (Optional) | Male-to-male or male-to-female | $0.40 – $0.85 |
Total (with just ESP32 and cable): ~$7.00 – $11.00 USD
Note: Most ESP32 boards have a built-in LED on GPIO 2. You don’t even need external components for this tutorial!
Quick Buy Links
| Component | Where to Find |
|---|---|
| ESP32 Development Board | AliExpress |
| USB Data Cable | AliExpress |
| LED Kit (Various Colors) | AliExpress |
| 220Ω Resistors (Pack) | AliExpress |
| Breadboard + Jumper Kit | AliExpress |

Why VS Code + PlatformIO? (Say Goodbye to Arduino IDE)
Most beginners start with the Arduino IDE. It’s simple. It works. But it has limits.
| Feature | Arduino IDE | VS Code + PlatformIO |
|---|---|---|
| Autocomplete | ❌ Basic or none | ✅ Intelligent (IntelliSense) |
| Code suggestions | ❌ No | ✅ Yes (GitHub Copilot optional) |
| Project organization | ❌ Single file only | ✅ Multiple files + folders |
| Library management | ❌ Manual ZIP install | ✅ One-click library search |
| Git integration | ❌ No | ✅ Built-in |
| Multiple platforms | ⚠️ Limited | ✅ 1000+ boards |
| Professional tool | ❌ No | ✅ Yes (industry standard) |
For quick tests? Arduino IDE is fine.
For building robots, managing complex code, and learning professional tools? VS Code + PlatformIO is the answer.
I use VS Code for everything:
ESP32 robotics code
Python scripts for data analysis
Web development for Roborear
GitHub Copilot for AI-assisted coding
One editor. Everything in one place.

Step 1: Installing VS Code and PlatformIO
1.1 Download and Install VS Code
Go to code.visualstudio.com
Download the version for your operating system (Windows, Mac, Linux)
Install it (default settings are fine)
1.2 Install PlatformIO Extension
Open VS Code
Click the Extensions icon on the left sidebar (or press Ctrl+Shift+X)
Search for “PlatformIO IDE”
Click Install (it’s the one with the little ant logo)
Wait for the installation to complete (it may take a few minutes)
1.3 Verify PlatformIO is Working
After installation, you’ll see a new icon on the left sidebar (looks like an ant head)
Click it. You should see “PlatformIO Home”
Congratulations! You now have a professional embedded development environment.

Step 2: Creating Your First PlatformIO Project
2.1 Start a New Project
Click the PlatformIO icon (ant) on the left sidebar
Click “New Project”
Fill in:
| Field | What to Enter |
|---|---|
| Name | Blink_LED (or anything you like) |
| Board | Search and select DOIT ESP32 DEVKIT V1 |
| Framework | Arduino (this is the easiest for beginners) |
| Location | Keep default or choose your folder |
Click “Finish”
PlatformIO will now create your project and download the necessary tools. This may take a minute or two.

2.2 Understanding the Project Structure
Your project folder will look like this:
Blink_LED/ ├── .pio/ (PlatformIO build files - don't touch) ├── .vscode/ (VS Code settings) ├── include/ (Header files - for advanced projects) ├── lib/ (Custom libraries - for later) ├── src/ (YOUR CODE GOES HERE!) │ └── main.cpp (This is where you'll write code) ├── platformio.ini (Project configuration file) └── .gitignore (For Git version control)
For now, we only care about src/main.cpp and platformio.ini.
Step 3: Writing Your First Code (The Blink Sketch)
Open src/main.cpp. Delete everything in it. Copy and paste this code:
// ============================================================ // ESP32 Blink LED - First Robotics Program // This blinks the built-in LED on GPIO 2 // ============================================================ // The setup function runs once when the board powers on void setup() { // Initialize the built-in LED pin as an output pinMode(LED_BUILTIN, OUTPUT); } // The loop function runs repeatedly forever void loop() { digitalWrite(LED_BUILTIN, HIGH); // Turn the LED ON delay(1000); // Wait 1 second (1000 milliseconds) digitalWrite(LED_BUILTIN, LOW); // Turn the LED OFF delay(1000); // Wait 1 second }
If you haven’t set up VS Code with PlatformIO yet, follow this guide first -> I Used Arduino IDE for 3 Months. Then I Found VS Code + PlatformIO and Never Went Back
What Each Line Means
| Code | What It Does |
|---|---|
void setup() | Runs once when the board starts. Used for initialization. |
pinMode(LED_BUILTIN, OUTPUT) | Tells the ESP32 that GPIO 2 is an OUTPUT pin (we want to send voltage out, not read it) |
void loop() | Runs repeatedly, forever. This is where the action happens. |
digitalWrite(LED_BUILTIN, HIGH) | Sends 3.3V to the pin. LED turns ON. |
delay(1000) | Pauses the program for 1000 milliseconds (1 second) |
digitalWrite(LED_BUILTIN, LOW) | Sends 0V to the pin. LED turns OFF. |
The result: LED on for 1 second, off for 1 second, repeating forever.
Step 4: Understanding the platformio.ini File
Open platformio.ini. It should look like this:
[env:doit_esp32_devkit_v1] platform = espressif32 board = doit_esp32_devkit_v1 framework = arduino monitor_speed = 115200
| Setting | What It Means |
|---|---|
platform = espressif32 | We’re using Espressif’s ESP32 platform |
board = doit_esp32_devkit_v1 | The specific board model |
framework = arduino | Using Arduino framework (easiest for beginners) |
monitor_speed = 115200 | Serial monitor baud rate (we’ll use this later) |
You don’t need to change anything here. Just know it exists.
Step 5: Connecting Your ESP32
5.1 Connect the Board
Plug your ESP32 into your computer using a USB cable.
Important: Use a data cable, not just a charging cable. Many USB cables only have power wires, no data wires. If your computer doesn’t detect the board, try a different cable.
5.2 Select the Correct Port
In VS Code, look at the bottom status bar (blue bar at the bottom)
You’ll see something like: COM3 or /dev/ttyUSB0 (depending on your OS)
If you don’t see a port:
Windows: Check Device Manager under “Ports (COM & LPT)”
Mac/Linux: Try unplugging and re-plugging the board

Step 6: Uploading Your Code
6.1 Build and Upload
Click the “Upload” arrow (→) at the bottom of VS Code (next to the checkmark and plug icons)
Or press: Ctrl+Alt+U (Windows/Linux) or Cmd+Alt+U (Mac)
6.2 Watch the Terminal
A terminal panel will open at the bottom showing:
Processing doit_esp32_devkit_v1... Compiling .pio/build/doit_esp32_devkit_v1/src/main.cpp Linking .pio/build/doit_esp32_devkit_v1/firmware.elf Checking size .pio/build/doit_esp32_devkit_v1/firmware.elf RAM: [=== ] 8.2% (used 42808 bytes from 524288) Flash: [= ] 6.1% (used 79602 bytes from 1310720) Uploading...
6.3 The Moment of Truth
After a few seconds, you should see:
Leaving... Hard resetting via RTS pin...
And on your ESP32, the blue LED should start blinking! ON for 1 second, OFF for 1 second.
(Photo: ESP32 with blue LED glowing)
6.4 Troubleshooting Upload Failures
If the upload fails, you might see a “Connecting…” message that hangs.
The Fix: Some ESP32 boards need to be put into “download mode” manually:
Hold down the BOOT button on the ESP32
Press and release the EN (Reset) button
Release the BOOT button
Try uploading again
This is normal for many ESP32 boards. After a few uploads, you’ll get used to it.
Step 7: Optional – Adding an External LED
Want to blink an external LED? Here’s how:
Wiring
| Component | Connect To |
|---|---|
| LED Anode (long leg) | GPIO 5 (or any free pin) through a 220Ω resistor |
| LED Cathode (short leg) | GND |
Modified Code
// Define which pin the LED is connected to #define EXTERNAL_LED 5 void setup() { pinMode(LED_BUILTIN, OUTPUT); pinMode(EXTERNAL_LED, OUTPUT); } void loop() { // Blink built-in LED digitalWrite(LED_BUILTIN, HIGH); digitalWrite(EXTERNAL_LED, LOW); delay(500); digitalWrite(LED_BUILTIN, LOW); digitalWrite(EXTERNAL_LED, HIGH); delay(500); }
Now the built-in LED and external LED will blink alternately!

Final Thoughts
Blinking an LED might seem small. But it’s the first step toward building robots that move, see, and think.
Every expert was once a beginner. Every complex robot started with a single blinking light.
So take a moment. Watch that LED blink. You just programmed a microcontroller.
That’s not nothing. That’s everything.
Now go build something cool.
Ready to build something that moves? start with the ESP32 RC Car project -> Build Your Own ESP32 RC Car: Wireless Joystick Controller Guide for Beginners







One Comment