Advertisement
microrobotics

Hi-Link V21 AI Voice Recognition Kit

Mar 31st, 2023
1,198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. 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.
  3.  
  4. 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.
  5.  
  6. 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
  7. */
  8.  
  9. #include <HardwareSerial.h>
  10.  
  11. #define VHM_RX_PIN 16
  12. #define VHM_TX_PIN 17
  13.  
  14. HardwareSerial VHM_Serial(2);
  15.  
  16. void setup() {
  17.   Serial.begin(115200);
  18.   VHM_Serial.begin(9600, SERIAL_8N1, VHM_RX_PIN, VHM_TX_PIN);
  19.  
  20.   Serial.println(F("Hi-Link V21 AI Voice Recognition Kit"));
  21. }
  22.  
  23. void loop() {
  24.   if (VHM_Serial.available()) {
  25.     uint8_t cmd = VHM_Serial.read();
  26.  
  27.     switch (cmd) {
  28.       case 1:
  29.         Serial.println(F("Command 1: Turn on light"));
  30.         break;
  31.       case 2:
  32.         Serial.println(F("Command 2: Turn off light"));
  33.         break;
  34.       case 3:
  35.         Serial.println(F("Command 3: Play music"));
  36.         break;
  37.       case 4:
  38.         Serial.println(F("Command 4: Pause music"));
  39.         break;
  40.       default:
  41.         Serial.print(F("Unknown command: "));
  42.         Serial.println(cmd);
  43.         break;
  44.     }
  45.   }
  46. }
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement