EasyManuals Logo

SunFounder ESP32 User Manual

Default Icon
771 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #94 background imageLoading...
Page #94 background image
SunFounder ESP32 Starter Kit
Code
Note:
You can open the file 5.8_pot.ino under the path of esp32-starter-kit-main\c\codes\5.8_pot.
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, rotate the potentiometer and you will see the brightness of the LED change
accordingly. At the same time you can see the analog and voltage values of the potentiometer in the serial monitor.
How it works?
1. Define constants for pin connections and PWM settings.
const int potPin = 14; // Potentiometer connected to GPIO14
const int ledPin = 26; // LED connected to GPIO26
// PWM settings
const int freq = 5000; // PWM frequency
const int resolution = 12; // PWM resolution (bits)
const int channel = 0; // PWM channel
Here the PWM resolution is set to 12 bits and the range is 0-4095.
88 Chapter 1. For Arduino User

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the SunFounder ESP32 and is the answer not in the manual?

SunFounder ESP32 Specifications

General IconGeneral
BrandSunFounder
ModelESP32
CategoryController
LanguageEnglish