Voice Control LED Indicator Light Using Arduino and Bluetooth

Controlling the LED indicator light with voice commands may seem like a challenging feature, but in reality, it is quite easy to implement. We can quickly achieve this by using an Arduino UNO development board in serial communication with the HC-06 Bluetooth module and a smartphone to send voice commands to the HC-06 Bluetooth module. To receive voice commands, we use the “Arduino Bluetooth Voice Controller” Android application, which can be downloaded from the Play Store (link provided at the end of the article).

Materials Required

● Arduino UNO development board

● HC-06 Bluetooth module

● LED indicator lights (red and green)

● 220-ohm resistors (2 pieces)

● Arduino Bluetooth Voice Controller (download from Play Store)

● Breadboard

● Jumper wires

HC-06 Bluetooth Module

Bluetooth can operate in two modes:

1. AT command setting mode

2. Working mode

In AT command setting mode, we can configure Bluetooth properties such as the name of the Bluetooth signal, password, operating baud rate, etc. The working mode is a mode where we can send and receive data between the PIC microcontroller and the Bluetooth module. Therefore, in this tutorial, we will only use the working mode for testing. The AT command setting mode is left as the default setting. The device name will be HC-05, the password will be 0000 or 1234, and most importantly, the default baud rate for all Bluetooth modules is 9600.

The module operates at a 5V power supply, and the signal pins operate at 3.3V, so the module has a built-in 3.3V voltage regulator. Therefore, we do not have to worry. Among the six pins, the working mode only uses four pins. The pin connection table is as follows:

Serial Number

HC-05 Module Pins

MCU Pins

PIC Pins

1

Vcc

Vdd

Pin 31

2

Gnd

Gnd

Pin 32

3

Tx

RC6 / Tx / CK

Pin 25

4

Rx

RC7 / Rx / DT

Pin 26

5

State

NC

NC

6

EN(Enable)

NC

NC

Circuit Diagram

The circuit diagram for the voice-controlled LED indicator light is shown below. When uploading code to the Arduino UNO, disconnect the Rx and Tx pins and reconnect them after uploading the code.

Voice Control LED Indicator Light Using Arduino and Bluetooth

Code and Explanation

The complete Arduino code for controlling the LED indicator light with voice commands is provided at the end of this article. Here, we will briefly introduce several parts of the code.

In the code below, we define the Rx and Tx pins.

  1. int TxD = 11;

  2. int RxD = 10;

Copy Code

Now, set pins 2 and 3 of the Arduino as outputs.

  1. pinMode(2, OUTPUT);

  2. pinMode(3, OUTPUT);

Copy Code

In the void loop() function, the Arduino continuously checks the input value and controls the LED based on the voice commands. According to the given voice command, the Arduino will turn the LED on or off. We store all received commands in the variable “Value“.

If the value is “all LED turn on“, both LEDs will turn on. We have written similar code for turning on or off individual LEDs for other voice commands.

  1. if (bluetooth.available())

  2. {

  3. value = bluetooth.readString();

  4. if (value == “all LED turn on”){

  5. digitalWrite(2, HIGH);

  6. digitalWrite(3, HIGH);

  7. }

  8. if (value == “all LED turn off”){

  9. digitalWrite(2, LOW);

  10. digitalWrite(3, LOW);

  11. }

  12. if (value == “turn on Red LED”){

  13. digitalWrite(2, HIGH);

  14. }

  15. if (value == “turn on green LED”){

  16. digitalWrite(3, HIGH);

  17. }

  18. if (value == “turn off red LED”){

  19. digitalWrite(2, LOW);

  20. }

  21. if (value == “turn off green LED”){

  22. digitalWrite(3, LOW);

  23. }

  24. }

Copy Code

Working Process

The working process of the voice-controlled LED indicator light is shown below:

Voice Control LED Indicator Light Using Arduino and Bluetooth

Step 1: – Connect all components according to the circuit diagram; disconnect the Rx and Tx pins while uploading the code.

Step 2: – Download the free “Arduino Bluetooth Voice Controller” application from the Play Store.

Step 3: – Open the application and follow the instructions in the image below. First, click “Connect to Bluetooth Device” and select your Bluetooth module, and check if it is connected. Then click the microphone icon to speak and send voice commands to the HC-06 module.

Voice Control LED Indicator Light Using Arduino and Bluetooth

Note: When you first connect your smartphone to the Bluetooth module, it will ask for a password, use 0000 or 1234.

Step 4: – After setting everything up, you just need to use the application to send voice commands, which will then be sent to the HC-06 Bluetooth module, and then HC-06 will communicate with the Arduino UNO serially, executing tasks based on the commands. Below shows the commands and the actions to be executed after receiving the commands:

Serial Number

Command

Action

1

all LED turn on Turn on red and green LED indicator lights

2

all LED turn off Turn off red and green LED indicator lights

3

turn on Red LED Turn on red LED indicator light

4

turn on green LED Turn on green LED indicator light

5

turn off red LED Turn off red LED indicator light

6

turn off green LED Turn off green LED indicator light

Code

Please click “Read the Original” to download the complete code used in this article.

Leave a Comment

×