1. Chapter LED
This chapter is the Start Point in the journey to build and explore ESP32-S3 WROOM electronic projects. We will start with simple “Blink” project.
1.1. Project 1.1 Blink
In this project, we will use ESP32-S3 WROOM to control blinking a common LED.
1.1.1. Component List
ESP32-S3 WROOM x1 |
USB cable x1 |
|---|---|
|
|
1.1.1.1. Power
ESP32-S3 WROOM needs 5v power supply. In this tutorial, we need connect ESP32-S3 WROOM to computer via Type C cable to power it and program it. We can also use other 5v power source to power it.
In the following projects, we only use Type C cable to power ESP32-S3 WROOM by default.
1.1.2. Sketch
According to the circuit, when the GPIO2 of ESP32-S3 WROOM output level is high, the LED turns ON. Conversely, when the GPIO2 ESP32-S3 WROOM output level is low, the LED turns OFF. Therefore, we can let GPIO2 circularly output high and low level to make the LED blink.
Upload the following Sketch:
Freenove_ESP32_S3_WROOM_Board_Lite\Sketches\Sketch_01.1_Blink.
Next we will introduce two ways to upload code to ESP32-S3 WROOM.
1.1.2.1. Option 1:
Connect ESP32-S3 WROOM to computer.
Open Arduino IDE. Click Tools->Upload Mode. Select UART0 / Hardware CDC.
Before uploading the code, click “ Tools “, “ Board “ and select “ESP32S3 Dev Module “.
Select the serial port.
Note that the computer port number of each user may be different. Please select the correct serial port according to your computer. Taking the window system as an example, my computer recognizes that the communication interface of the ESP32-S3-WROOM is COM3, so I select COM3.
Note
For macOS users, if the uploading fails, please set the baud rate to 115200 before clicking “Upload Using Programmer”.
Click the Upload button and it will compile and upload the Sketch to the ESP32-S3-WROOM.
Wait for the Sketch upload to complete, and observe the ESP32-S3-WROOM. You can see that the blue LED (IO2) on the board flashes cyclically.
If you have any concerns, please contact us via: support@freenove.com.
1.1.2.2. Option 2:
Connect ESP32-S3 WROOM to computer.
Open Arduino IDE. Click Tools->USB CDC On Boot: Enable.
Select the serial port.
Note that the computer port number of each user may be different. Please select the correct serial port according to your computer. Taking the window system as an example, my computer recognizes that the communication interface of the ESP32-S3-WROOM is COM25, so I select COM25.
Click the Upload button and it will compile and upload the Sketch to the ESP32-S3-WROOM.
Wait for the Sketch upload to complete, and observe the ESP32-S3-WROOM. You can see that the blue LED (IO2) on the board flashes cyclically.
1.1.2.3. Sketch_01.1_Blink
The following is the program code:
1/**********************************************************************
2* Filename : Blink
3* Description : Make an led blinking.
4* Auther : www.freenove.com
5* Modification: 2024/08/27
6**********************************************************************/
7#define LED_BUILTIN 2
8// the setup function runs once when you press reset or power the board
9void setup() {
10
11 // initialize digital pin LED_BUILTIN as an output.
12 pinMode(LED_BUILTIN, OUTPUT);
13}
14
15// the loop function runs over and over again forever
16void loop() {
17 digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
18 delay(1000); // wait for a second
19 digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
20 delay(1000); // wait for a second
21}
The Arduino IDE code usually contains two basic functions: void setup() and void loop().
After the board is reset, the setup() function will be executed firstly, and then the loop() function.
setup() function is generally used to write code to initialize the hardware. And loop() function is used to write code to achieve certain functions. loop() function is executed repeatedly. When the execution reaches the end of loop(), it will jump to the beginning of loop() to run again.
- Reset()
Reset operation will lead the code to be executed from the beginning. Switching on the power, finishing uploading the code and pressing the reset button will trigger reset operation.
In the circuit, ESP32-S3 WROOM’s GPIO2 is connected to the LED, so the LED pin is defined as 2.
1#define LED_BUILTIN 2
This means that after this line of code, all LED_BUILTIN will be treated as 2.
In the setup () function, first, we set the LED_BUILTIN as output mode, which can make the port output high level or low level.
1// initialize digital pin LED_BUILTIN as an output.
2pinMode(LED_BUILTIN, OUTPUT);
Then, in the loop () function, set the LED_BUILTIN to output high level to make LED light up.
1digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
Wait for 1000ms, that is 1s. Delay () function is used to make control board wait for a moment before executing the next statement. The parameter indicates the number of milliseconds to wait for.
1delay(1000); // wait for a second
Then set the LED_BUILTIN to output low level, and LED light off. One second later, the execution of loop () function will be completed.
1digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
2delay(1000); // wait for a second
The loop() function is constantly being executed, so LED will keep blinking.
1.1.2.4. Reference
- void pinMode(int pin, int mode);
Configures the specified pin to behave either as an input or an output.
Parameters
pin: the pin number to set the mode of.
mode: INPUT, OUTPUT, INPUT_PULLDOWM, or INPUT_PULLUP.
- void digitalWrite (int pin, int value);
Writes the value HIGH or LOW (1 or 0) to the given pin which must have been previously set as an output.
For more related functions, please refer to https://www.arduino.cc/reference/en/

