EasyManuals Logo

Freenove ESP32 User Manual

Default Icon
159 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 #99 background imageLoading...
Page #99 background image
Need support? support@freenove.com
97
Chapter 8 Buzzer
www.freenove.com
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
playMelody(tuneCamDis, beatCamDis, 100);
break;
case MELODY_CAM_FAILURE:
playMelody(tuneCamFailure, beatCamFailure, 500);
break;
case MELODY_BEEP_1:
playMelody(tuneBeep1, beatBeep1, 300);
break;
case MELODY_BEEP_2:
playMelody(tuneBeep2, beatBeep2, 100);
break;
case MELODY_DHTG:
playMelody(tuneDhtg, beatDhtg, 500);
case MELODY_BB_CLEAR_1:
playMelody(tuneBb1, beatBb1, 100);
break;
case MELODY_BB_CLEAR_2:
playMelody(tuneBb2, beatBb2, 100);
break;
default:
break;
}
}
vTaskDelete(xTaskGetCurrentTaskHandle());
}
Define the pin for the buzzer. ESP32's PWM channel, number of bits, and frequency.
3
4
5
6
#define BUZZER_PIN (33)
#define BUZZER_CHN (0)
#define BUZZER_BIT (10)
#define BUZZER_FREQ (5000)
Configure the pin to control the buzzer:
1. Configure the PWM channel, frequency, and number of digits.
2. Associate the PWM signal output channel with the pin that controls the buzzer.
3. Control the duty cycle of the PWM channel to 0.
4. Control the buzzer to make no sound.
10
11
12
13
14
15
void setupBuzzer() {
ledcSetup(BUZZER_CHN, BUZZER_FREQ, BUZZER_BIT); // setup pwm channel
ledcAttachPin(BUZZER_PIN, BUZZER_CHN);
ledcWrite(BUZZER_CHN, 0);
ledcWriteTone(BUZZER_CHN, 0);
}
Call setBuzzer() to control the buzzer to emit sounds with different frequencies.
17
18
void setBuzzer(uint16_t freq) {
if (freq != 0) {

Questions and Answers:

Question and Answer IconNeed help?

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

Freenove ESP32 Specifications

General IconGeneral
BrandFreenove
ModelESP32
CategoryComputer Hardware
LanguageEnglish

Related product manuals