Arduino Tutorial: JARVIS v1 | How to make a Home Automation
This project demonstrates the integration to build an intelligent system to control home appliances for elderly
Components and supplies
1
Breadboard (generic)
4
Relay Module (Generic)
10
Jumper wires (generic)
1
Bluetooth Low Energy (BLE) Module (Generic)
1
Arduino Nano R3
Tools and machines
1
Soldering iron (generic)
Apps and platforms
1
Arduino IDE
Project description
Code
Sample Code
arduino
1//Coded By: Angelo Casimiro (4/27/14) 2//Voice Activated Arduino (Bluetooth + Android) 3//Feel free to modify it but remember to give credit 4 5String voice; 6int 7led1 = 2, //Connect LED 1 To Pin #2 8led2 = 3, //Connect LED 2 To Pin #3 9led3 = 4, //Connect LED 3 To Pin #4 10led4 = 5, //Connect LED 4 To Pin #5 11led5 = 6; //Connect LED 5 To Pin #6 12//--------------------------Call A Function-------------------------------// 13void allon(){ 14 digitalWrite(led1, HIGH); 15 digitalWrite(led2, HIGH); 16 digitalWrite(led3, HIGH); 17 digitalWrite(led4, HIGH); 18 digitalWrite(led5, HIGH); 19} 20void alloff(){ 21 digitalWrite(led1, LOW); 22 digitalWrite(led2, LOW); 23 digitalWrite(led3, LOW); 24 digitalWrite(led4, LOW); 25 digitalWrite(led5, LOW); 26} 27//-----------------------------------------------------------------------// 28void setup() { 29 Serial.begin(9600); 30 pinMode(led1, OUTPUT); 31 pinMode(led2, OUTPUT); 32 pinMode(led3, OUTPUT); 33 pinMode(led4, OUTPUT); 34 pinMode(led5, OUTPUT); 35} 36//-----------------------------------------------------------------------// 37void loop() { 38 while (Serial.available()){ //Check if there is an available byte to read 39 delay(10); //Delay added to make thing stable 40 char c = Serial.read(); //Conduct a serial read 41 if (c == '#') {break;} //Exit the loop when the # is detected after the word 42 voice += c; //Shorthand for voice = voice + c 43 } 44 if (voice.length() > 0) { 45 Serial.println(voice); 46//-----------------------------------------------------------------------// 47 //----------Control Multiple Pins/ LEDs----------// 48 if(voice == "*all on") {allon();} //Turn Off All Pins (Call Function) 49 else if(voice == "*all off"){alloff();} //Turn On All Pins (Call Function) 50 51 //----------Turn On One-By-One----------// 52 else if(voice == "*TV on") {digitalWrite(led1, HIGH);} 53 else if(voice == "*fan on") {digitalWrite(led2, HIGH);} 54 else if(voice == "*computer on") {digitalWrite(led3, HIGH);} 55 else if(voice == "*bedroom lights on") {digitalWrite(led4, HIGH);} 56 else if(voice == "*bathroom lights on") {digitalWrite(led5, HIGH);} 57 //----------Turn Off One-By-One----------// 58 else if(voice == "*TV off") {digitalWrite(led1, LOW);} 59 else if(voice == "*fan off") {digitalWrite(led2, LOW);} 60 else if(voice == "*computer off") {digitalWrite(led3, LOW);} 61 else if(voice == "*bedroom lights off") {digitalWrite(led4, LOW);} 62 else if(voice == "*bathroom lights off") {digitalWrite(led5, LOW);} 63//-----------------------------------------------------------------------// 64voice="";}} //Reset the variable after initiating 65
Project Repo
Sample Code
arduino
1//Coded By: Angelo Casimiro (4/27/14) 2//Voice Activated Arduino (Bluetooth 3 + Android) 4//Feel free to modify it but remember to give credit 5 6String 7 voice; 8int 9led1 = 2, //Connect LED 1 To Pin #2 10led2 = 3, //Connect LED 11 2 To Pin #3 12led3 = 4, //Connect LED 3 To Pin #4 13led4 = 5, //Connect LED 4 14 To Pin #5 15led5 = 6; //Connect LED 5 To Pin #6 16//--------------------------Call 17 A Function-------------------------------// 18void allon(){ 19 digitalWrite(led1, 20 HIGH); 21 digitalWrite(led2, HIGH); 22 digitalWrite(led3, HIGH); 23 digitalWrite(led4, 24 HIGH); 25 digitalWrite(led5, HIGH); 26} 27void alloff(){ 28 digitalWrite(led1, 29 LOW); 30 digitalWrite(led2, LOW); 31 digitalWrite(led3, LOW); 32 digitalWrite(led4, 33 LOW); 34 digitalWrite(led5, LOW); 35} 36//-----------------------------------------------------------------------// 37 38void setup() { 39 Serial.begin(9600); 40 pinMode(led1, OUTPUT); 41 pinMode(led2, 42 OUTPUT); 43 pinMode(led3, OUTPUT); 44 pinMode(led4, OUTPUT); 45 pinMode(led5, 46 OUTPUT); 47} 48//-----------------------------------------------------------------------// 49 50void loop() { 51 while (Serial.available()){ //Check if there is an available 52 byte to read 53 delay(10); //Delay added to make thing stable 54 char c = Serial.read(); 55 //Conduct a serial read 56 if (c == '#') {break;} //Exit the loop when the # is 57 detected after the word 58 voice += c; //Shorthand for voice = voice + c 59 } 60 61 if (voice.length() > 0) { 62 Serial.println(voice); 63//-----------------------------------------------------------------------// 64 65 //----------Control Multiple Pins/ LEDs----------// 66 if(voice 67 == "*all on") {allon();} //Turn Off All Pins (Call Function) 68 else if(voice 69 == "*all off"){alloff();} //Turn On All Pins (Call Function) 70 71 //----------Turn 72 On One-By-One----------// 73 else if(voice == "*TV on") {digitalWrite(led1, 74 HIGH);} 75 else if(voice == "*fan on") {digitalWrite(led2, HIGH);} 76 else 77 if(voice == "*computer on") {digitalWrite(led3, HIGH);} 78 else if(voice == 79 "*bedroom lights on") {digitalWrite(led4, HIGH);} 80 else if(voice == "*bathroom 81 lights on") {digitalWrite(led5, HIGH);} 82 //----------Turn Off One-By-One----------// 83 84 else if(voice == "*TV off") {digitalWrite(led1, LOW);} 85 else if(voice == 86 "*fan off") {digitalWrite(led2, LOW);} 87 else if(voice == "*computer off") 88 {digitalWrite(led3, LOW);} 89 else if(voice == "*bedroom lights off") {digitalWrite(led4, 90 LOW);} 91 else if(voice == "*bathroom lights off") {digitalWrite(led5, LOW);} 92//-----------------------------------------------------------------------// 93 94voice="";}} //Reset the variable after initiating 95
Downloadable files
Connection
Connection

Connection
Connection

Comments
Only logged in users can leave comments