Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- The Hi-Link V21 AI Voice Recognition Kit uses the ESP32 microcontroller and the VHM-314 module for voice recognition. Here's an example of how to use the V21 AI Voice Recognition Kit to recognize a set of predefined voice commands and print them to the serial monitor.
- Upload the complete code to your ESP32 board and open the Serial Monitor. Ensure that the VHM-314 voice recognition module is connected to the ESP32 using the defined RX and TX pins. The VHM-314 module should be configured with the predefined voice commands before uploading the code. Consult the VHM-314 documentation for instructions on configuring voice commands.
- Once the code is uploaded, you can start giving voice commands to the V21 AI Voice Recognition Kit. The recognized commands will be printed to the Serial Monitor. You can modify the code in the switch statement to execute the desired
- */
- #include <HardwareSerial.h>
- #define VHM_RX_PIN 16
- #define VHM_TX_PIN 17
- HardwareSerial VHM_Serial(2);
- void setup() {
- Serial.begin(115200);
- VHM_Serial.begin(9600, SERIAL_8N1, VHM_RX_PIN, VHM_TX_PIN);
- Serial.println(F("Hi-Link V21 AI Voice Recognition Kit"));
- }
- void loop() {
- if (VHM_Serial.available()) {
- uint8_t cmd = VHM_Serial.read();
- switch (cmd) {
- case 1:
- Serial.println(F("Command 1: Turn on light"));
- break;
- case 2:
- Serial.println(F("Command 2: Turn off light"));
- break;
- case 3:
- Serial.println(F("Command 3: Play music"));
- break;
- case 4:
- Serial.println(F("Command 4: Pause music"));
- break;
- default:
- Serial.print(F("Unknown command: "));
- Serial.println(cmd);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement