Introduction
- In this article, I will explain the voice-based light ON/OFF with the Android app In Arduino Mega 2560.
- It can be fully controlled by voice.
- It can be controlled by the app.
Parts Of Lists
- Arduino Mega2560
- Bluetooth
- LEDs- 05
- Hook-Up Wires
- Bread Board
Connection
Step 1: Connection from Bluetooth To Arduino Mega 2560
| Bluetooth | Board |
| Vcc | 5v |
| Gnd | Gnd |
| Tx | Rx |
| Rx | Tx |
Step 2: Connection for the LEDs
| Leds | Postive side | Negative side |
| Led1 | 12 | Gnd |
| Led2 | 13 | Gnd |
| Led3 | 14 | Gnd |
| Led4 | 15 | Gnd |
| Led5 | 16 | Gnd |
Programming
- //Coded By: Angelo Casimiro (4/27/14)
- //Voice Activated Arduino (Bluetooth + Android)
- //Feel free to modify it but remember to give credit
- String voice;
- int
- led1 = 12, //Connect LED 1 To Pin #2
- led2 = 13, //Connect LED 2 To Pin #3
- led3 = 14, //Connect LED 3 To Pin #4
- led4 = 15, //Connect LED 4 To Pin #5
- led5 = 16; //Connect LED 5 To Pin #6
- //--------------------------Call A Function-------------------------------//
- void allon()
- {
- digitalWrite(led1, HIGH);
- digitalWrite(led2, HIGH);
- digitalWrite(led3, HIGH);
- digitalWrite(led4, HIGH);
- digitalWrite(led5, HIGH);
- }
- void alloff()
- {
- digitalWrite(led1, LOW);
- digitalWrite(led2, LOW);
- digitalWrite(led3, LOW);
- digitalWrite(led4, LOW);
- digitalWrite(led5, LOW);
- }
- void setup()
- {
- Serial.begin(9600);
- pinMode(led1, OUTPUT);
- pinMode(led2, OUTPUT);
- pinMode(led3, OUTPUT);
- pinMode(led4, OUTPUT);
- pinMode(led5, OUTPUT);
- }
- void loop()
- {
- while (Serial.available()) { //Check if there is an available byte to read
- delay(10); //Delay added to make thing stable
- char c = Serial.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)
- {
- Serial.println(voice);
- //----------Control Multiple Pins/ LEDs----------//
- if (voice == "*all on")
- {
- allon();
- } //Turn Off All Pins (Call Function)
- else if (voice == "*all off")
- {
- alloff();
- } //Turn On All Pins (Call Function)
- //----------Turn On One-By-One----------//
- else if (voice == "*TV on")
- {
- digitalWrite(led1, HIGH);
- } else if (voice == "*fan on")
- {
- digitalWrite(led2, HIGH);
- } else if (voice == "*computer on")
- {
- digitalWrite(led3, HIGH);
- } else if (voice == "*bedroom lights on")
- {
- digitalWrite(led4, HIGH);
- } else if (voice == "*bathroom lights on")
- {
- digitalWrite(led5, HIGH);
- }
- //----------Turn Off One-By-One----------//
- else if (voice == "*TV off")
- {
- digitalWrite(led1, LOW);
- } else if (voice == "*fan off")
- {
- digitalWrite(led2, LOW);
- } else if (voice == "*computer off")
- {
- digitalWrite(led3, LOW);
- } else if (voice == "*bedroom lights off")
- {
- digitalWrite(led4, LOW);
- } else if (voice == "*bathroom lights off")
- {
- digitalWrite(led5, LOW);
- }
- voice = "";
- }
- } //Reset the variable after initiating
- We can control the LEDs by the voice, through the Android app
- If we want to turn ON the light, we set the voice as the "Light ON"
- If we want to turn OFF the light, we set the voice as the "Light OFF"
- We can also set the voice for "All on" and "All Off".
- They can work on a one-by-one process.
- We want to download the app from the play store.
Output


Shobana JPosted Jul 8, 2016, 4:08 AM
Keep sharing.Nice one
Sr KarthigaPosted Jul 5, 2016, 10:33 AM
Thank you prasanna
Sr KarthigaPosted Jul 5, 2016, 10:32 AM
Thank you vignesh main sir
Sr KarthigaPosted Jul 5, 2016, 10:32 AM
Thank you raja
Santhakumar MunuswamyPosted Jun 25, 2016, 2:50 AM
Nice share
Prasanna MuraliPosted Jun 21, 2016, 9:32 PM
Nice one..
Vignesh ManiPosted Jun 17, 2016, 5:38 AM
Nice share
RajaPosted Jun 16, 2016, 3:03 AM
Good One..