int tb1 = 2; int tb2 = 3; int tb3 = 4; void setup () { Serial.begin (9600); pinMode (tb1, OUTPUT); pinMode (tb2, OUTPUT); pinMode (tb3, OUTPUT); } void loop () { while (Serial.available ()) {// Check the byte to read delay (30);// Delay to be more stable char c = Serial.read ();// proceed to read if (c == '#') {break;} // Exit the loop when detecting the word # data + = c;// data = data + c } if (data.length ()> 0) { Serial.println (data); if (data == "turn on device 1" || data == "Turn on device 1" || data == "1") {digitalWrite (tb1, HIGH);} else if (data == "turn off device 1" || data == "Turn off device 1" || data == "a") {digitalWrite (tb1, LOW);} // tb1 if (data == "turn on device 2" || data == "Turn on device 2" || data == "2") {digitalWrite (tb2, HIGH);} else if (data == "turn off device 2" || data == "Turn off device 2" || data == "b") {digitalWrite (tb2, LOW);} // tb2 if (data == "turn on device 3" || data == "Turn on device 3" || data == "3") {digitalWrite (tb3, HIGH);} else if (data == "turn off device 3" || data == "Turn off device 3" || data == "c") {digitalWrite (tb3, LOW);} // tb3 data = "";}} // Reset variables
Step 5:
Instructions on how to make devices that turn on / off lights and fans in Vietnamese Picture 13
After connecting the modules on the phone, we download the Bluetooth Voice Control software here and install it on the Android phone.
Instructions on how to make devices that turn on / off lights and fans in Vietnamese Picture 14
After installation, we open the software and select the device.
Instructions on how to make devices that turn on / off lights and fans in Vietnamese Picture 15
Here, you choose to connect to the device named tail 06 HC.
Instructions on how to make devices that turn on / off lights and fans in Vietnamese Picture 16
Now say "turn on device 1" and "turn off device 1" to turn on and turn off the light. To change this phrase into other phrases, you can edit it in the Arduino code file.
Instructions on how to make devices that turn on / off lights and fans in Vietnamese Picture 17
With this software, you can set to turn on, turn off 3 devices. To be able to control all the devices in the house with this software, you can add more switches.
Instructions on how to make devices that turn on / off lights and fans in Vietnamese Picture 18