Introduction
This experiment demonstrates how to control devices (e.g., LED) using voice commands with a voice recognition module.
Components Needed
- Voice Recognition Module
- Arduino (e.g., Uno, Nano)
- LED
- 220-ohm Resistor
- Jumper wires
Circuit Setup
- Connect the voice recognition module to the Arduino using the appropriate pins for TX and RX.
- Connect the LED to one of the digital pins of the Arduino, using a 220-ohm resistor in series.
Ensure that the module is powered and properly wired to the Arduino.
Code for Voice Recognition Module Control
Upload the following code to your Arduino to control an LED using voice commands:
#include
VoiceRecognitionV3 voiceRecognition;
int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
voiceRecognition.begin();
voiceRecognition.load(1, "voice_commands.dat"); // Load the voice commands
}
void loop() {
int voiceCommand = voiceRecognition.readVoice();
if (voiceCommand == 1) {
digitalWrite(ledPin, HIGH); // Turn on LED
} else if (voiceCommand == 2) {
digitalWrite(ledPin, LOW); // Turn off LED
}
}
Explanation
The voice recognition module listens for predefined commands. When a recognized command is spoken, the corresponding action (e.g., turning an LED on/off) is performed.
Troubleshooting
- If the module does not recognize your voice, ensure the command is properly trained and the microphone is working.
- If the LED does not respond, check the wiring and verify the voice commands are loaded correctly.