Thursday, May 16, 2019

DIY VOICE HOME AUTOMATION USING ARDUINO AND ANDROID


DIY VOICE HOME AUTOMATION USING ARDUINO AND ANDROID

  • Circuit diagram




  • Code for Arduino UNO



//Edison Media
//Thejus B Oommen
String voice;
int RED = 2;
int GREEN = 3 ;
int BLUE = 4;
int YELLOW = 5;
void RedOn(){
digitalWrite (RED, LOW);
}
void RedOff(){
digitalWrite (RED, HIGH);
}
void GreenOn(){
digitalWrite (GREEN, LOW);
}
void GreenOff(){
digitalWrite (GREEN, HIGH);
}
void BlueOn(){
digitalWrite (BLUE, LOW);
}
void BlueOff(){
digitalWrite (BLUE, HIGH);
}
void YellowOn(){
digitalWrite (YELLOW, LOW);
}
void YellowOff(){
digitalWrite (YELLOW, HIGH);
}
void allon() {
digitalWrite (RED, LOW);
digitalWrite (GREEN, LOW);
digitalWrite (BLUE, LOW);
digitalWrite (YELLOW, LOW);
}
void alloff() {
digitalWrite (RED, HIGH);
digitalWrite (GREEN, HIGH);
digitalWrite (BLUE, HIGH);
digitalWrite (YELLOW, HIGH);
}
void setup() {
Serial.begin(9600);
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(YELLOW, OUTPUT);
}
void loop() {
while(Serial.available()) {
delay(10);
char c=Serial.read();
if(c=='#')
{break; }
voice += c;
}
if (voice.length() > 0) {
Serial.println(voice);
if (voice == "on" || voice == "all")
{
allon() ;
}
else if (voice == "switch off" || voice=="switch off all")
{
alloff() ;
}
else if(voice =="tubelight" || voice =="tubelight on"){
RedOn();
}
else if(voice =="switch off tubelight" || voice =="tubelight off"){
RedOff();
}
else if(voice =="bedroom" || voice =="bedroom on"){
YellowOn();
}
else if( voice =="switch off bedroom" || voice =="bedroom off" ){
YellowOff();
}
else if(voice =="bulb" || voice =="bulb on"){
BlueOn();
}
else if(voice =="switch off bulb" || voice =="bulb off"){
BlueOff();
}
else if(voice =="ceiling fan" || voice =="ceiling fan on"){
GreenOn();
}
else if(voice =="switch off ceiling fan" || voice =="ceiling fan off"){
GreenOff();
}
voice="";
}
}





Please  subscribe our channel

1 comment:

  1. Good job, but I need your help , I did exactly what you did, the schematic is the same , the app is the same but the application did not paired with the arduino , even when I talk the serial monitor is working , I hear What I say in the android , the bluetooth is connected , its LED is stopping blinking which means that the bluetooth is paired. I am lost , if there any setting in the android?

    ReplyDelete