ESP32 Starter Kit
3. Wiring Diagram
4. Test Code
If the development board outputs a high level, the buzzer will emit sound. If it outputs a low level, the buzzer will stop
ringing. Thus, its code is similar to light up an LED.
/*
keyestudio ESP32 Inventor Learning Kit
Project 7 Active Buzzer
http://www.keyestudio.com
*/
int buzzer = 5; //Define buzzer connected to IO5 pin
void setup() {
pinMode(buzzer, OUTPUT);//Set the output mode
}
void loop() {
digitalWrite(buzzer, HIGH); //IO5 pin outputs a high level to cause the buzzer to emit␣
˓→sound
delay(1000); //Delay 1000ms
digitalWrite(buzzer, LOW); //IO5 outputs a low level to prevent the buzzer to emit␣
˓→sound
(continues on next page)
64 Chapter 8. Arduino Tutorial