Embedded System Project 1 : LED Blink with ESP32 on Arduino IDE

Michelle Lim
6 min readFeb 4, 2023

--

Hi, I’m Michelle and this is my first blog on my blog series of the embedded system projects ✨🤩

A disclaimer, this is the very first time I’m dealing with microcontrollers and Arduino IDE. But thankfully, this course that I’m taking (II2260 Embedded Systems) will guide me step by step in every project that I will be doing. I will also be recording my progress through these blogs written weekly 😆

The first project I’m making is a simple one, the code is actually already given in the basic examples section, so it will also be easy for you guys who will be starting from 0 😉 . Now, shall we begin? :)

PREPARATIONS BEFORE STARTING THE PROJECT

1. Buy the Components

First of all, buy the components you need! As for this project, you will only be needing 2 components: the ESP32 development board and micro-USB cable. For references, I bought them at 2 different stores, shown in the picture down below (this is not an endorsement 😊).

ESP-32 development board (it’s actually cheaper in Shopee when I bought it, but I needed it to be sent on the same day so I bought it in Tokopedia 😅); LINK — https://tokopedia.link/eDhLVSvW8wb
Micro-USB Cable 50cm (I bought it in Shopee, from a different store from where I bought the ESP 32); LINK — https://shp.ee/kausqfw

2. Download the Arduino IDE

After buying the components, you need to download the Arduino IDE where you will sketch and run the program. Go to https://www.arduino.cc/en/Main/Software and download the newest version: Arduino IDE 2.0.3 (as of this blog is published).

This is what you should see when opening the link

Click on the download option you will be installing the Arduino IDE on. As for me, I’m using Macbook Pro with M1 chip, so I’ll click on the bottom bolded “macOS”.

Click on the bolded option to choose the operating system you’re using

You should then be directed to the download page as shown below.

Arduino IDE download page

Click on the “JUST DOWNLOAD” option and the downloading process will begin immediately.

NOTE: As for me, this Arduino version somehow won’t work on my computer 😢, so I’m using the previous version which is the Arduino IDE 1.8.19. However, this tutorial will still be applicable for both versions. So, don’t worry ! 😉

3. Configure Arduino IDE and Install Package Board ESP-32

After downloading, you will need to configure and install the package board ESP-32 we will be using. Follow these instructions in doing it 🙌

1. Go to preferences and fill in https://dl.espressif.com/dl/package_esp32_index.json in the Additional Boards Manager URLs. Then, click OK.

Arduino > Preferences > Additional Boards Manager URLs > Paste https://dl.espressif.com/dl/package_esp32_index.json > OK

2. Go to Tools > Board > Boards Manager. In the Boards Manager, type “esp32” and click enter. You will be shown the esp32 board installation section, click Install.

Tools > Board > Boards Manager > Type “esp32” > Install

3. After installing, go to Tools > Board > ESP32 Arduino. Scroll down, and click DOIT ESP32 DEVKIT V1.

Tools > Board > ESP32 Arduino > DOIT ESP32 DEVKIT V1

4. Install the USB to UART driver for serial data communication between ESP and the computer. Go to https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers and scroll down. Choose according to which operating system you’re using. Click on the option and it will immediately start downloading.

https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers > CP210x <OS>

4. Connect the board to the computer, and choose the USB to UART port. NOTE: when you connect the board, you should see a red light on the board.

Connect board to PC; Tools > Port > USBtoUART

Finally, we’re ready to start the first ESP32 project: LED Blink. As I said earlier, this project is quite simple, so keep calm and enjoy the process! 😄

ESP-32 PROJECT 1: LED BLINK

1. Find the code Blink that we will be using for this project on File > Examples > 01.Basics > Blink. A window will then show up.

File > Examples > 01.Basics > Blink

Analysis on the code:

Blink Code

void setup() function is a function that will only run once when you press reset or power the board. It has a pinMode(LED_BUILTIN, OUTPUT) that marks that the output will be shown on the LED built in. The code then moves on to the loop function that will run over and over again forever. void loop() has digitalWrite(LED_BUILTIN, HIGH) that will turn the LED on with high voltage level. It then delays for 1000ms or 1 second with the code delay(1000). It will then turn the LED off by making the voltage low in digitalWrite(LED_BUILTIN, LOW). It will then delay for 1 second in code delay(1000) before turning the LED on again. This means that in the loop function, the LED will be on for 1 second and then off for 1 second repeatedly until the code is changed.

2. To make the LED blink, we click on the verify (☑️ symbol) and then upload the sketch (➡️ symbol). NOTE: if the upload won’t start, click on the BOOT button on the ESP32 when uploading.

Verify > Upload
BOOT Button on ESP32 Board

3. After uploading, the LED (the blue light) on our ESP32 will start blinking by 1 second delay.

LED Blinking; delay(1000)

4. We’re actually done for our first project, but since I’m curious about the delay in blinking, I decided to change the number in code delay(1000) to see how fast the LED is blinking after the code change. 🧐

LED Blinking; delay(500)

As expected, the LED is blinking twice as fast as the first one with 500ms delay. This is actually already quite fast but how fast will it blink with a 0.1s or 100ms delay? 🤔

LED Blinking; delay(100)

I know it’s expected to be super fast, but it’s so fast that my eyes hurt a bit while looking at it as it’s 10 times faster than the first one. 🥲

In conclusion, the blinking frequency depends on the delay time. The less delay time, the more and faster it blinks, and vice versa.

So yea, that’s the end of our first Embedded System Project: LED Blink with ESP32 Development Board on Arduino IDE. (yeah!! 🥳) Stay tune for the next projects and stay safe and healthy 🥰

--

--