Blinking the Internal LED in ESP32

Jonathan Arthurito Aldi Sinaga
3 min readFeb 4, 2023

--

Hello, so this is my first project in ESP32. So, here’s my experience while doing it :D.

Setting up the Configuration

First, you need to setup the software part. You should install Arduino IDE and install some other driver and library ( such as the
CP210x USB to UART Bridge VCP Drivers, ESP32 library because Arduino IDE is by default only can be used for Arduino ). You can see my github repo if you want to see the steps. You can click it here.

After you set the environment, then we can go to the hardware part. For this project, you only need an ESP32 and a Micro USB. You can buy ESP32 through online e-commerce like Tokopedia, Shopee, etc. I bought the I already have my old Handphone charger, so there’s no need for me to buy another Micro USB cable. Note that not all Micro USB cable can transfer data. My new phone charger could not transfer data :D.

Doing the Blinking

So, in ESP32, there are 2 types of void or procedure.

  1. setup(). This procedure only runs when the ESP32 was activated or plugged with the Micro USB for the first time.
  2. loop(). This procedure runs after the setup() runs and looping until the Micro USB is plugged off.

The ESP32 setup has a kind of C or C++ syntax. I able to read that because I already learned about C in Algorithm and Data Structure. But, I is still different from C.

When you plugged in the Micro USB cable to the ESP32 for the literally first time, the internal red LED will be lighted up.

State of ESP32 when you plugged it for the very first time

But, that’s not what we want. We want to blink the internal blue LED. I don’t really know what to do beside copy-paste the blinking code :D. I just take it for granted about the code. When I plugged it again, it wasn’t just turn on just like what I thought would be. I must upload the code first.

Upload in Arduino IDE
#define LED 2

void setup() {
// Set pin mode
pinMode(LED,OUTPUT);
}

void loop() {
delay(50);
// you can set the delay time by adjusting the parameter of delay();
digitalWrite(LED,HIGH);
delay(50);
digitalWrite(LED,LOW);
}

So, i just clicked the upload button in Arduino IDE. But, I still wasn’t uploaded yet. Instead, I got uploading error. So, I searched it on the internet. So, I got the solution. I had to click the BOOT button while the code is being uploaded.

Upload Error in Arduino IDE

But, I still didn’t know why the blue led still off. Actually, I have to click the EN button. Then, the LED started to blink :D. You can adjust the interval of the blinking by changing the the delay in the code. Also note that the unit of the delay is in microsecond, not in second.

I got succesful in the first attempt because my Micro USB cable could transfer the data. Many of my friend’s Micro USB cable can’t do that.

That’s all from me, thank you for reading :D.

--

--