Devices & Components
Arduino Uno Rev3
jumper wires for arduino
4 channel Relay board
HC-05 Bluetooth Module
Hardware & Tools
Soldering iron (generic)
Hot glue gun (generic)
Software & Tools
pro
Project description
Code
Code for Bluetooth voice controlled appliances with 'OK GOOGLE'
arduino
Bluetooth voice controlled appliances with 'OK GOOGLE'
1 String voice; 2 3#define FAN 10 4#define TUBELIGHT 9 5#define BULB 8 6 7void setup() 8{ // put your setup code here, to run once: 9 Serial.begin(9600); 10 pinMode(FAN, OUTPUT); 11 pinMode(TUBELIGHT, OUTPUT); 12 pinMode(BULB, OUTPUT); 13 analogWrite(TUBELIGHT,255); // Since LED must be off in the beginning 14 analogWrite(FAN,255); 15 digitalWrite(BULB,HIGH); 16} 17 18void loop() { 19 20 while (Serial.available()) //Check if there is an available byte to read 21 { 22 delay(10); //Delay added to make thing stable 23 char c = Serial.read(); //Conduct a serial read 24 if (c == '#') {break;} //Exit the loop when the # is detected after the word 25 voice += c; //Shorthand for voice = voice + c 26 } 27 28 if (voice.length() > 0) { 29 Serial.println(voice); 30 //----------Control Multiple Pins/ LEDs----------// 31 32 if(voice == "tubelight")// 33 { 34 analogWrite(TUBELIGHT,0); 35 analogWrite(FAN,255); 36 digitalWrite(BULB,HIGH); 37 } 38 else if(voice == "green")// 39 { 40 analogWrite(TUBELIGHT,255); 41 analogWrite(FAN,255); 42 digitalWrite(BULB,HIGH); 43 } 44 else if(voice == "fan")// 45 { 46 analogWrite(TUBELIGHT,255); 47 analogWrite(FAN,0); 48 digitalWrite(BULB,HIGH); 49 } 50 51 else if(voice == "bulb")// 52 { 53 analogWrite(TUBELIGHT,0); 54 analogWrite(FAN,255); 55 digitalWrite(BULB,LOW); 56 } 57 58 else if(voice == "go")// 59 { 60 digitalWrite(BULB,HIGH); 61 } 62 else if(voice == "lights")// 63 { 64 analogWrite(TUBELIGHT,0); 65 analogWrite(FAN,0); 66 digitalWrite(BULB,LOW); 67 } 68 else if(voice == "good night")// 69 { 70 analogWrite(TUBELIGHT,255); 71 analogWrite(FAN,255); 72 digitalWrite(BULB,HIGH); 73 } 74 75voice=""; //Reset the variable after initiating 76 }} 77 78
Downloadable files
Circuit Diagram
circuit diagram for Bluetooth voice controlled appliances with 'OK GOOGLE'
Circuit Diagram

Circuit Diagram
circuit diagram for Bluetooth voice controlled appliances with 'OK GOOGLE'
Circuit Diagram

Comments
Only logged in users can leave comments