Anda di halaman 1dari 4

EXPERIMENT 4

Aim:
Voice Controlled Home automation Using Ardiuno

Theory:
Things Required:
- Arduino Mega Board
- HC-05 Bluetooth Module
-Three LEDs (Red, Yellow & Green)
- Arduino USB Cable
- Breadboard
-Jumper Wires M-M.
Steps to Follow:
-Make the connections as per the diagram.
-Connect the USB cable with Arduino & Computer.
-Open the Ardiuno IDE --> Tools ---> and check the port is connected or not and run the
command “sudochmoda+rw /dev/ttyACM0”
-Download the Program Voice-Activation-Arduino in the system.
-Click on Upload Option to download the program in Arduino.
Procedure to Follow on Phone:
- Search for AMR_Voice app in Google Playstore.
- You would find an app named "BT Voice Control for Arduino"
- Install that Application in your phone
- Once Installed it will Automatically Enable your Bluetooth.
If in case it asks for your permission to Enable Bluetooth, please allow it
- Click TheMenu Button in the right Corner
- Click Connect Robot.
-It will show you the List of Available Bluetooth devices
-Please select the device which has it's name as HC-05
If you couldn't find your device it means that your bluetooth module is not powered
properly
-Once connected please press the MIC button and use any of the following voice commands
to control your Arduino
light on, light off
fan on, fan off
ac on, ac off
open, close
Note: (You can use your own dialog to control the LED)
Voice Commands refer that you should speak the above words to your phone

Code:
String voice;
int led1 = 13;//Connect LED 1 To Pin #13
int led2 = 12;
int led3 = 11;

//--------------------------Call A Function-------------------------------//
void lighton(){
digitalWrite(led1, HIGH);
}

void led2on(){
digitalWrite(led2, HIGH);
}
void led3on(){
digitalWrite(led3, HIGH);
}

void lightoff(){
digitalWrite(led1, LOW);
}

void led2off(){
digitalWrite(led2, LOW);
}

void led3off(){
digitalWrite(led3, LOW);
}

//-----------------------------------------------------------------------//
void setup() {
Serial1.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
}
//-----------------------------------------------------------------------//
void loop() {
while (Serial1.available()){ //Check if there is an available byte to read
delay(10); //Delay added to make thing stable
char c = Serial1.read(); //Conduct a serial read
if (c == '#') {break;} //Exit the loop when the # is detected after the word
voice += c; //Shorthand for voice = voice + c
}
if (voice.length() > 0) {
Serial1.println(voice);
//-----------------------------------------------------------------------//
//----------Control Multiple Pins/ LEDs----------//
if(voice == "*light on") {lighton();} //Turn Off All Pins (Call Function)
else if(voice == "*light off"){lightoff();} //Turn On All Pins (Call Function)

if(voice == "*on") {led2on();} //Turn Off All Pins (Call Function)


else if(voice == "*of"){led3off();} //Turn On All Pins (Call Function)

if(voice == "*online") {led3on();} //Turn Off All Pins (Call Function)


else if(voice == "*ofline"){led3off();} //Turn On All Pins (Call Function)
//-----------------------------------------------------------------------//
voice="";}} //Reset the variable after initiating

Image:

Conclusion:
Thus we have studied and implemented Voice Control Home automation Using Ardiuno

Anda mungkin juga menyukai