ESP8266 - Keypad - Beep
This tutorial instructs you how to use the ESP8266 to produce a beep sound when a keypad is pressed. Specifically, the ESP8266 controls the piezo buzzer and emitting a brief sound for each key press.
Hardware Preparation
Or you can buy the following sensor kits:
1 | × | DIYables Sensor Kit (30 sensors/displays) | |
1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables.
Overview of Keypad and Piezo Buzzer
If you are unfamiliar with keypad and Piezo Buzzer (including pinouts, operations, and programming), the following tutorials can provide assistance:
The ezBuzzer library has been created to enable buzzers to beep or play melodies without interfering with other code.
Wiring Diagram
This image is created using Fritzing. Click to enlarge image
See more in ESP8266's pinout and how to supply power to the ESP8266 and other components.
ESP8266 Code
Detailed Instructions
To get started with ESP8266 on Arduino IDE, follow these steps:
- Check out the how to setup environment for ESP8266 on Arduino IDE tutorial if this is your first time using ESP8266.
- Wire the components as shown in the diagram.
- Connect the ESP8266 board to your computer using a USB cable.
- Open Arduino IDE on your computer.
- Choose the correct ESP8266 board, such as (e.g. NodeMCU 1.0 (ESP-12E Module)), and its respective COM port.
- Connect the ESP8266 to a computer using a USB cable.
- Open the Arduino IDE and select the correct board and port.
- Click to the Libraries icon on the left bar of the Arduino IDE.
- Search for “keypad” and locate the keypad library created by Mark Stanley and Alexander Brevig.
- Then, press the Install button to complete the installation of the keypad library.
- Search for “ezBuzzer”, then locate the buzzer library by ArduinoGetStarted.
- Press the Install button to install the ezBuzzer library.
- Copy the code and open it in Arduino IDE.
- Click the Upload button in Arduino IDE to compile and upload the code to ESP8266.
- Press certain keys on the keypad.
- Listen for a beep and then check the Serial Monitor to view the result.
Code Explanation
Check out the line-by-line explanation contained in the comments of the source code!