Lesson 01: Your First Command — Making Light Blink

Robotics from Scratch · Lesson 01 · Beginner · ~12 min read · Updated April 2026


The Moment You Decide to Learn Is the Hardest Step

Right now, sitting where you are, you are closer to building a real robot than most people will ever be in their entire lives.

You have a laptop. You have a USB cable — the same one that charges your phone. You have internet access. And now, with about $4 and twelve minutes, you are going to write a program that makes something in the physical world happen.

Not "kind of sort of" happen. Actually happen. A light will blink. On a circuit board. Because you told it to.

That is not a small thing. That is the same moment every engineer, every maker, every person who has ever built something real has lived through. The first time you realize your words — written in a text editor, sent down a wire — moved something in the world. It is quiet. It is small. But it changes how you see everything.

Let's begin.


What You Will Learn and Why It Matters

By the end of this lesson, you will understand three things that will underpin everything you build from here:

1. Your laptop is already a control center.
It has more processing power than the computers that landed on the moon. Right now it is mostly telling a screen what to display. By the end of this lesson, it will also be sending commands to another piece of hardware.

2. A microcontroller is a very small, very dedicated computer.
It is not like your laptop. It does not run an operating system with a desktop and a web browser. It runs one program. Repeatedly. Forever, or until you give it a new one. This is exactly what you want for a robot.

3. Code is just structured commands.
You have been giving commands your whole life. "Pass the salt." "Set an alarm for 7 AM." "Call me when you land." Code is the same idea — you are just writing instructions in a language the machine can understand, with a grammar that is more precise than English.

The project you build in this lesson will make an LED blink. It is the "Hello, World" of hardware. Every robotics course starts here, including this one. The goal is not the blinking light. The goal is understanding why it worked.


The Story Behind the Blink

Before you touch any hardware, let me tell you the short version of why this works.

Deep inside your laptop, there is a small chip that manages how information flows in and out of your computer through the USB port. When you plug something into USB — a phone, a drive, a microcontroller — that chip notices, identifies the device, and opens a channel of communication.

For the ESP32-C3, that channel is a serial connection. Your laptop talks to the board. The board listens. When your laptop sends the right sequence of bytes, the board does what those bytes say: set this pin HIGH. Set that pin LOW. Repeat forever.

The blinking light is just the board turning power on and off on one of its output pins. The LED is connected to that pin. When the pin is HIGH, electricity flows, the LED glows. When it is LOW, electricity stops, the LED goes dark. Do that fast enough, and you see it blink.

That is the entire project. On. Off. On. Off. 500 milliseconds each way.

Everything else in this course is variations on this theme.


What You Need

The Hardware

The board we are using is the ESP32-C3 mini. Here is why it is the right choice for beginners:

Note: If you already have a different microcontroller — an Arduino Uno, a Nano, a Raspberry Pi Pico — this course will work on those too. The core concepts are identical. The code will look a little different. I will note the differences as we go.

Where to buy:

You need one board for this lesson. Nothing else. The LED we will blink is already on the board.

The Software

You need two things: a text editor and a tool that sends your code to the board.

VS Code (recommended, free, works on Windows, Mac, and Linux)
: Download at code.visualstudio.com

PlatformIO (a free extension for VS Code that handles everything else)
: Inside VS Code, press Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (Mac) to open Extensions. Search for "PlatformIO IDE." Click Install. It takes about 2 minutes.

PlatformIO is the tool that will compile your code — turn it from readable text into machine instructions — and then upload it to the board through the USB cable. It handles all the complicated setup so you do not have to.


Step 1: Install PlatformIO and Create Your First Project

Open VS Code. On the left sidebar, click theExtensions icon (the puzzle piece). Search for PlatformIO IDE. Install it. When it finishes, VS Code may ask you to to reload — do that.

You will see a new icon appear on the left sidebar: a small alien head. That is the PlatformIO logo. Click it.

Create a New Project

Click + New Project. Give it a name: `blink`. For the board, search for and select: Espressif ESP32-C3 DevKitM-1. Set the framework to Arduino. Choose a project directory (anywhere you like). Click Finish.

PlatformIO will download the board support files in the background. This takes a minute or two the first time. You will see a progress indicator in the bottom bar. Wait for it to finish.

When it is done, your project structure looks like this:

```
blink/
└── src/
└── main.cpp ← Your code goes here
```

PlatformIO also created a file called `platformio.ini` — that is the project configuration. You will not touch it for now, but it is there.


Step 2: The Code

Open `src/main.cpp`. You will see some placeholder text. Delete everything and replace it with this:

```cpp
#include <Arduino.h>

// The built-in LED on the ESP32-C3 DevKitM-1 is on GPIO 8.
// We give it a name so our code is readable.
#define LED_PIN 8

void setup() {
// setup() runs once when the board powers on
pinMode(LED_PIN, OUTPUT); // Tell the board: this pin is an output
}

void loop() {
// loop() runs forever, over and over, until you upload new code
digitalWrite(LED_PIN, HIGH); // Turn the LED on
delay(500); // Wait 500 milliseconds
digitalWrite(LED_PIN, LOW); // Turn the LED off
delay(500); // Wait 500 milliseconds
}
```

That is the entire program. Let me explain each part before you upload it.


Understanding the Code, Line by Line

`#include <Arduino.h>`
: This brings in a library of basic commands — `pinMode`, `digitalWrite`, `delay` — that work across many different microcontroller boards. It is how the same code can run on an Arduino and an ESP32. You will see this line in almost every project.

`#define LED_PIN 8`
: A `#define` is a label. We are saying "whenever you see LED_PIN in this code, replace it with the number 8." GPIO 8 is the pin on the ESP32-C3 that the built-in RGB LED is connected to. You do not need to wire anything — the LED is already on that pin. Using a name instead of a raw number makes the code easier to read and change.

`void setup()`
: This is a special function. It runs exactly once, right when the board first powers on or gets reset. Think of it as the "getting ready" phase. In our case, we use it to tell the board: "GPIO 8 is going to be an output pin." That means it will send electricity out, rather than reading electricity in.

`void loop()`
: After setup() finishes, loop() starts — and it runs forever. The moment it reaches the last line, it starts again at the first line. This is the microcontroller doing what it is designed to do: running one task, repeatedly, reliably. In our case: on, wait, off, wait, on, wait, off, wait — forever.

`digitalWrite(LED_PIN, HIGH)`
: `digitalWrite` sets a pin to either HIGH (sending 3.3 volts) or LOW (sending 0 volts). HIGH is on. LOW is off. When we set GPIO 8 to HIGH, electricity flows through the LED and it lights up.

`delay(500)`
: Pauses the program for 500 milliseconds — half a second. Then the next line runs.

That is the entire program. On. Wait. Off. Wait. Repeat forever.


Step 3: Upload to the Board

Connect your ESP32-C3 to your laptop with a USB-C cable.

In VS Code, look at the bottom of the window. You will see a small arrow pointing right: → Upload. That is the upload button. Click it.

PlatformIO will:

  1. Compile your code (turn it into instructions the chip understands)
  2. Find the board on the USB port
  3. Upload the instructions
  4. Reset the board

You will see output scrolling in the terminal panel at the bottom. When it says something like "Hard resetting via RTS pin..." — look at your board.

The small RGB LED on the board will be blinking. Green. Half a second on, half a second off. Indefinitely.

You just made that happen.


What Just Happened

A few things happened in sequence that are worth understanding:

Your laptop sent the compiled program to the board over USB. The USB cable is doing double duty — it is both powering the board and carrying your program to it. Once the program is uploaded, the board remembers it. The USB cable can be unplugged and the board will still run its program. This is important: the program lives on the chip itself, not on your laptop.

The chip ran setup() once, then entered loop(). This is the fundamental pattern of almost every microcontroller program. Do some setup. Then do the main task, forever. Microcontrollers do not have screens, keyboards, or complex operating systems. They do one focused thing reliably and without stopping. A washing machine runs one loop. A smoke detector runs one loop. A robot runs one loop — that loop just has more inside it.

The LED turned on and off because electricity flowed and stopped flowing. There is a complete circuit inside the board: power → LED → GPIO pin → ground. When the pin is HIGH, electricity takes that path and the LED lights. When the pin is LOW, the path is closed, no electricity flows, the LED goes dark. This is the same circuit you will use for motors, sensors, buzzers — everything that follows. The pattern is always: complete the circuit to make something happen. Break the circuit to stop it.


Key Concepts Learned


Troubleshooting

The board does not appear in the upload window.
Try a different USB cable. Some USB cables are charge-only — they have no data wires inside. You need a cable that can transfer data. Try the cable from your phone, if it is USB-C.

The IDE cannot find the board.
Open Device Manager (Windows), System Information (Mac), or run `ls /dev/tty*` in a terminal (Linux). The board will appear as something like `COM3` or `/dev/ttyUSB0`. If it does not appear, your board may be in a different mode — hold the BOOT button while pressing the RESET button, then try uploading again.

The LED is not lighting up.
Double-check that you selected the correct board (ESP32-C3 DevKitM-1). Different boards have the built-in LED on different GPIO pins. For this specific board, GPIO 8 is correct.


What's Next

You just made something happen in the physical world with code. You understand the loop. You understand the output pin. You understand that the USB cable is a bridge between your thoughts and the machine.

Now we build on that.

In Lesson 02, we will add an external LED — one you wire yourself on a breadboard. This introduces the concept of a circuit you build by hand, and you will use two pins instead of one: one to send power, one to control it. You will also learn what a breadboard is and why it makes prototyping nearly instant.

The goal of Lesson 02 is to give you the confidence to wire things yourself. After that, the hardware side of robotics will never feel intimidating again.

Start Lesson 02 →


CryptoTavern Robotics from Scratch is an evolving course. Each lesson improves over time as the community learns. If something was unclear, if you got stuck, or if something just worked and you want to say so — that is what the course is for.

Next lesson: Lesson 02 — Your First Circuit: Blinking an External LED