Controlling electronics with voice commands is one of the most exciting applications of IoT and embedded systems. In this project, you’ll learn how to build a voice-controlled LED system using an Arduino Uno, an HC-05 Bluetooth module, and a mobile app to send commands via Bluetooth.
We’ll control two LEDs (Red and Green) using simple voice commands like:
- “Red LED on”
- “Red LED off”
- “Green LED on”
- “Green LED off”
Components Required
Component | Quantity |
---|---|
Arduino Uno | 1 |
HC-05 Bluetooth Module | 1 |
Red LED | 1 |
Green LED | 1 |
220Ω Resistors | 2 |
Breadboard | 1 |
Jumper Wires | As needed |
Android Phone with Voice Control App | 1 |
Circuit Diagram & Connections
HC-05 Bluetooth Module:
HC-05 Pin | Connects To | Notes |
---|---|---|
VCC | 5V on Arduino | Power |
GND | GND on Arduino | Ground |
TXD | Pin 10 on Arduino | SoftwareSerial RX |
RXD | Pin 11 on Arduino | SoftwareSerial TX (via voltage divider) |
LEDs:
LED | Anode (Long Leg) | Cathode (Short Leg) | Resistor |
---|---|---|---|
Red LED | Pin 8 on Arduino | GND via 220Ω | Yes |
Green LED | Pin 9 on Arduino | GND via 220Ω | Yes |
How It Works
- The user gives a voice command through a mobile app (such as “Bluetooth Voice Control for Arduino”).
- The app converts the voice to text and sends it over Bluetooth.
- The Arduino receives the command and matches it with pre-defined phrases like
"RED LED ON"
or"GREEN LED OFF"
. - Based on the command, the corresponding LED turns ON or OFF.
Mobile App Configuration
You can use apps like:
- Arduino Bluetooth Control
- Arduino Voice Control
Steps:
- Pair your phone with the HC-05 module (default PIN:
1234
or0000
). - Open the app and connect to the HC-05 module.
- Use voice commands like:
- “Red LED on”
- “Green LED off”
- “Turn off red”
- etc.
If the command is recognized correctly and matches the code, the LED will respond accordingly.
Arduino code:
#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11); // RX, TX
const int redLED = 8;
const int greenLED = 9;
String command = "";
void setup() {
pinMode(redLED, OUTPUT);
pinMode(greenLED, OUTPUT);
Serial.begin(9600);
BT.begin(9600); // HC-05 default baud rate
Serial.println("Ready to receive voice commands...");
}
void loop() {
// Read from Bluetooth
while (BT.available()) {
char c = BT.read();
command += c;
delay(5); // Small delay to ensure complete string is received
}
// If we received a command, process it
if (command.length() > 0) {
Serial.println("Command: " + command);
// Convert command to uppercase for case-insensitive comparison
command.toUpperCase();
// Control logic using UPPERCASE strings
if (command.indexOf("RED LED ON") != -1) {
digitalWrite(redLED, HIGH);
Serial.println("Red LED turned ON");
}
else if (command.indexOf("RED LED OFF") != -1 || command.indexOf("TURN OFF RED") != -1) {
digitalWrite(redLED, LOW);
Serial.println("Red LED turned OFF");
}
else if (command.indexOf("GREEN LED ON") != -1) {
digitalWrite(greenLED, HIGH);
Serial.println("Green LED turned ON");
}
else if (command.indexOf("GREEN LED OFF") != -1 || command.indexOf("TURN OFF GREEN") != -1) {
digitalWrite(greenLED, LOW);
Serial.println("Green LED turned OFF");
}
command = ""; // Clear command buffer
}
}
Testing and Debugging Tips
- Open Serial Monitor to see incoming commands for debugging.
- If the command doesn’t work, type it manually in the Bluetooth app to test.
- Make sure the LED anode is connected to the correct digital pin, and the cathode goes through a resistor to GND.
Result
Once everything is set up:
- Saying “Red LED on” turns the red LED ON.
- Saying “Red LED off” turns it OFF.
- Saying “Green LED on” turns the green LED ON.
- Saying “Green LED off” turns it OFF.
Conclusion
This project is a simple yet powerful demonstration of how you can control electronic components wirelessly using voice commands. It introduces key concepts of serial communication, string parsing, and voice-to-text Bluetooth control in Arduino.
This is perfect for beginners looking to explore home automation or start with IoT!