EasyManua.ls Logo

SunFounder ESP32

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
Loading...
SunFounder ESP32 Starter Kit
Code
Note:
Open the 3.2_custom_tone.ino file under the path of esp32-starter-kit-main\c\codes\3.
2_custom_tone.
After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button.
Always displaying “Unknown COMxx”?
After the code is successfully uploaded, you will hear the passive buzzer play a sequence of 7 musical notes.
How it works?
1. Define constants for the buzzer pin and PWM resolution.
const int buzzerPin = 14; //buzzer pin
const int resolution = 8;
2. Define an array containing the frequencies of the 7 musical notes in Hz.
int frequencies[] = {262, 294, 330, 349, 392, 440, 494};
3. Create a function to play a given frequency on the buzzer for a specified duration.
50 Chapter 1. For Arduino User

Table of Contents