SunFounder ESP32 Starter Kit
Code
Note:
• You can open the file 2.2_fading_led.ino under the path of esp32-starter-kit-main\c\codes\2.
2_fading_led.
• After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button.
• Always displaying “Unknown COMxx”?
After the code is uploaded successfully, you can see the LED breathing.
How it works
1. Define constants and variables
const int ledPin = 26; // The GPIO pin for the LED
int brightness = 0;
int fadeAmount = 5;
• ledPin: The GPIO pin number where the LED is connected (in this case, GPIO 26).
• brightness: The current brightness level of the LED (initially set to 0).
• fadeAmount: The amount by which the LED’s brightness will change in each step (set to 5).
2. Initializes the PWM channel and configures the LED pin.
24 Chapter 1. For Arduino User