SuperKitz.com Project Manual
Voice Command Controlled LED using Arduino and Bluetooth DIY Kit
Using Arduino Uno or Nano and HC 06
In this DIY kit from Super kit we learn to control LEDs with voice command which seems to be a difficult task, but it’s easy and you can quickly build it. We just need an Arduino UNO to serially communicate with HC-06 Bluetooth module and a smartphone to send voice command to Bluetooth module HC-06. For receiving voice command we are using “Arduino Bluetooth Voice Controller” android app which you can download from play store (link is given below). Controlling You’r Home Lights using an arduino and you’r android phone. We would be able to control your home using an arduino and android phone. In this tutorial, we would be discussing the very basic turning on and off a led using an android app which has even a voice command.
Requirements :
- Computer with an internet connection
- Download and install Arduino IDE
- Arduino Bluetooth Voice Controller (Download from play store)
Components
Arduino Uno
USB 2.0 Male to Mini USB Cable
Jumper wires
Set of assorted LEDs
Resistor 220 ohm
Breadboard
HC-05 Bluetooth Module
Hardware
Arduino Uno
1 nos
Arduino Nano
Getting
Started with
Arduino UNO
Although there are many types of boards from arduino . Here we are going to be using the Arduino UNO as it is the most commonly used one. The arudino UNO has :
- The operating voltage is 5V
- The recommended input voltage will range from 7v to 12V
- Digital input/output pins are 14
- Analog i/p pins are 6
- DC Current for each input/output pin is 40 mA
- Flash Memory is 32 KB
- SRAM is 2 KB
- EEPROM is 1 KB
- CLK Speed is 16MHz
Another wonderful feature of the arduino is the option of using a add-on boards to the arduino which comes as a module and they are known as “Shields”
Pin out diagram
Arduino UNO
HC-06 Bluetooth Module:
HC-05 Bluetooth Module:
Bluetooth can operate in the following two modes:
- Command Mode
- Operating Mode
In Command Mode we will be able to configure the Bluetooth properties like the name of the Bluetooth signal, its password, the operating baud rate etc. The Operating Mode is the one in which we will be able to send and receive data between the PIC Microcontroller and the Bluetooth module. Hence in this tutorial we will be toying only with the Operating Mode. The Command mode will be left to the default settings. The Device name will be HC-05 and the password will be 0000 or 1234 and most importantly the default baud rate for all Bluetooth modules will be 9600.
The module works on 5V supply and the signal pins operate on 3.3V, hence a 3.3V regulator is present in the module itself. Hence we need not worry about it. Out of the six pins only four will be used in the Operating mode. The pin connection table is shown below
S.No | Pin on HC-05/HC-06 | Pin name on Arduino | |
1 | Vcc | +5V | |
2 | GND | GND | |
3 | Tx | Pin 11 | |
4 | Rx | PIn 10 | |
5 | State | No connection | |
6 | EN (Enable) | No connection |
|
Circuit Diagram
Circuit diagram for this Voice Controlled Lights is given below, while uploading the code in the Arduino UNO disconnect the Rx and Tx pins and connect again after the code is uploaded.
Wire up the LED and Bluetooth Module HC 06
With Arduino
Getting started with Arduino
Before starting any project, we need to interface Arduino with a computer. So we have to write and compile code for the Arduino to execute, as well as providing Arduino to function with the computer.
Installing The Arduino Software Package On Windows
Download a version of Arduino software suitable for your version of Windows from Arduino website / superkitzs.com. After downloading, check the instructions below to install the Arduino Integrated Development Environment (IDE).
CONNECT YOUR ARDUINO UNO BOARD WITH AN A B USB CABLE; SOMETIMES THIS CABLE IS CALLED A USB PRINTER CABLE
Note: Install the board drivers if you experience any trouble else continue with the rest of the steps.
If you used the Installer, as soon as you connect your board the Windows – from XP up to 10 – will install drivers automatically
If the board is not properly recognized when the zip package is downloaded and expanded, please follow the procedure below.
- START menu> CONTROL PANEL MENU
- From the control panel, check for System and Security
- Select system
- Select Device Manager from the System window
- Select open port named “Arduino UNO (COMxx)”, under Ports (COM & LPT). If there is no COM & LPT section, check “Other Devices” for “Unknown Device”.
- Choose the “Update Driver Software” option by right-clicking on the “Arduino UNO (COmxx)” port
- Navigate to the “Browse my computer for Driver software” option.
- Choose the driver file named “arduino. inf”, located in the “Drivers” folder of the Arduino Software download (not the “FTDI USB Drivers” sub-directory). If you are using an old version of the IDE (1.0.3 or older), Choose the Uno driver file named “Arduino UNO.inf”, If an old version of the IDE (1.0.3 or older) is used
- Thus the windows driver installation is completed
Select your board type : Arduino UNO and also select the port
Choose Tools –> Serial Port menu. This is likely to be COM3 or higher
Press CNTRL + A and press DELETE on keyboard for clearing the Arduino IDE page
Upload the program
Copy paste the code given below and click upload
Arduino Programming
Code and Explanation
The complete Arduino code for Voice controlled LEDs is given at the end. Here we are explaining few parts of code.
Here, in the below code we are defining the pins for Rx and Tx.
int TxD = 11; int RxD = 10;
Now, set pin 2nd and 3rd of the Arduino as output.
pinMode(2, OUTPUT); pinMode(3, OUTPUT);
In void loop function, Arduino will be checking the incoming values all the time and controls the LEDs as per the voice command. Arduino will turn on or off the LED according to the given Voice command. We are saving all the received command in variable “Value”
If the value is “all LED turn on” then both the LEDs turns ON, like this we have coded other voice commands for turning on or off the individual LED.
if (bluetooth.available()) { value = bluetooth.readString(); if (value == "all LED turn on"){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); } if (value == "all LED turn off"){ digitalWrite(2, LOW); digitalWrite(3, LOW); } if (value == "turn on Red LED"){ digitalWrite(2, HIGH); } if (value == "turn on green LED"){ digitalWrite(3, HIGH); } if (value == "turn off red LED"){ digitalWrite(2, LOW); } if (value == "turn off green LED"){ digitalWrite(3, LOW); } }
Working Procedure:
Step 1:- Connect all components as per the circuit diagram; disconnect Rx and Tx pins while uploading the code.
Step 2:- Download the app called “Arduino Bluetooth Voice Controller” which is free on play store. Click here to download.
Step 3:- Open the app and follow the image below, like the first click on “connect to Bluetooth device” and select your Bluetooth module and check if it is connected or not. Then click on the mic icon to speak and send the voice command to the HC-06 module.
Note: when you are connecting your Bluetooth module for the first time with your smartphone it will ask for the passcode, use 0000 or 1234.
Step 4:- After setting up all the things, you just have to send the voice command by using the app which is further sent to Bluetooth module HC-06 and the HC-06 serially communicate with the Arduino UNO and then the task is performed as per the command. The below shows the command and the action to be performed by the command:
S. No. | Command | Action |
1. | leds on | Both Red and Green LED turns ON |
2. | leds off | Both Red and Green LED turns OFF |
3. | red led on | Red LED turns ON |
4. | green led on | Green LED turns ON |
5. | red led off | Red LED turns OFF |
6. | green led off | Green LED turns OFF |
Sketch Code
#include <SoftwareSerial.h>
String value;
int TxD = 11;
int RxD = 10;
int servoposition;
SoftwareSerial bluetooth(TxD, RxD);
void setup() {
pinMode(2, OUTPUT); //Defining output pins
pinMode(3, OUTPUT);
Serial.begin(9600); // start serial communication at 9600bps
bluetooth.begin(9600); // initialising bluetooth
}
void loop() {
Serial.println(value);
if (bluetooth.available())
{
value = bluetooth.readString(); //Reading data from bluetooth
if (value == "leds on"){
digitalWrite(2, HIGH); //Turn the LED ON
digitalWrite(3, HIGH);
}
if (value == "leds off"){
digitalWrite(2, LOW); //Turn the LED OFF
digitalWrite(3, LOW);
}
if (value == "red led on"){
digitalWrite(2, HIGH);
}
if (value == "green led on"){
digitalWrite(3, HIGH);
}
if (value == "red led off"){
digitalWrite(2, LOW);
}
if (value == "green led off"){
digitalWrite(3, LOW);
}
}
}
Output
– After setting up all the things, you just have to send the voice command by using the app which is further sent to Bluetooth module HC-06 and the HC-06 serially communicate with the Arduino UNO and then the task is performed as per the command which turning on and off a led.
Further you can use this ito control multiple devices even TV.