soumil shah
Published © GPL3+

Smart House

Wireless house.

BeginnerFull instructions provided1,422
Smart House

Things used in this project

Code

voice controlled

Plain text
voice commands
#define CUSTOM_SETTINGS
#define INCLUDE_VOICE_RECOGNIZER_SHIELD
#define INCLUDE_MUSIC_PLAYER_SHIELD
#define INCLUDE_TERMINAL_SHIELD
/* Include 1Sheeld library. */
#include <OneSheeld.h>
int Bledpin=13;
int Yledpin=12;
int Gledpin=11;

/* Voice commands set by the user. */
const char playCommand[] = "play";
const char pauseCommand[] = "stop";
const char stopCommand[] = "yellow";
const char nextCommand[] = "green";
const char BlueCommand[] = "blue";

void setup()
{
  pinMode(13,OUTPUT);
  pinMode(12,OUTPUT);
  pinMode(11,OUTPUT);
  /* Start Communication. */
  OneSheeld.begin();
  /* Error Commands handiling. */
  VoiceRecognition.setOnError(error);
  
  VoiceRecognition.start();
}

void loop () 
{
  /* Check if new command received. */
  if(VoiceRecognition.isNewCommandReceived())
  {
    /* Compare the play command. */
    if(!strcmp(playCommand,VoiceRecognition.getLastCommand()))
    {
      digitalWrite(13,HIGH);
      digitalWrite(12,HIGH);
      digitalWrite(11,HIGH);
    }
    /* Compare the pause command. */
    else if (!strcmp(pauseCommand,VoiceRecognition.getLastCommand()))
    {
       digitalWrite(13,LOW);
      digitalWrite(12,LOW);
      digitalWrite(11,LOW);
    }
    /* Compare the stop command. */
    else if (!strcmp(stopCommand,VoiceRecognition.getLastCommand()))
    {
       digitalWrite(13,LOW);
      digitalWrite(12,HIGH);
       digitalWrite(11,LOW);
    }
    /* Compare the next command. */
    else if (!strcmp(nextCommand,VoiceRecognition.getLastCommand()))
    {
      digitalWrite(13,LOW);
      digitalWrite(11,HIGH);
      digitalWrite(12,LOW);
       
    }
    else if (!strcmp(BlueCommand,VoiceRecognition.getLastCommand()))
    {
      
      digitalWrite(12,LOW);
      digitalWrite(13,HIGH);
       digitalWrite(11,LOW);
    }
  }
}

/* Error checking function. */
void error(byte errorData)
{
  /* Switch on error and print it on the terminal. */
  switch(errorData)
  {
    case NETWORK_TIMEOUT_ERROR: Terminal.println("Network timeout");break;
    case NETWORK_ERROR: Terminal.println("Network Error");break;
    case AUDIO_ERROR: Terminal.println("Audio error");break;
    case SERVER_ERROR: Terminal.println("No Server");break;
    case SPEECH_TIMEOUT_ERROR: Terminal.println("Speech timeout");break;
    case NO_MATCH_ERROR: Terminal.println("No match");break;
    case RECOGNIZER_BUSY_ERROR: Terminal.println("Busy");break;
  }
}

smart house

Plain text
controlling appliance with keypad sheild and phone call
#include <OneSheeld.h>
int ledPin1 = 13;
int ledPin2 = 12;
int ledPin3 = 11;
int ledPin4 = 10;


void setup() 
{
  
  OneSheeld.begin();
  pinMode(ledPin1,OUTPUT);
   pinMode(ledPin2,OUTPUT);
    pinMode(ledPin3,OUTPUT);
     pinMode(ledPin4,OUTPUT);

  Phone.setOnCallStatusChange(&myFunction);
 
}

void loop()
{

  char* number = Phone.getNumber();
  
         
  
 if(Keypad.isRowPressed(0) && Keypad.isColumnPressed(0))
  {
   
    digitalWrite(ledPin1,HIGH);
    delay(500);
    TextToSpeech.say("lights on sir");

  }
   
    if(Keypad.isRowPressed(0) && Keypad.isColumnPressed(1))
  {
    
    digitalWrite(ledPin1,LOW);
    TextToSpeech.say("lights off sir");
    


  }
  
   if(Keypad.isRowPressed(0) && Keypad.isColumnPressed(2))
  {
    
    digitalWrite(ledPin2,HIGH);
   TextToSpeech.say("alright sir its on");


  }
   if(Keypad.isRowPressed(0) && Keypad.isColumnPressed(3))
  {
    
    digitalWrite(ledPin2,LOW);
      TextToSpeech.say("ok sir lights off");
   


  }
   if(Keypad.isRowPressed(1) && Keypad.isColumnPressed(0))
  {
    
    digitalWrite(ledPin3,HIGH);
   TextToSpeech.say("its on sir");
  }
   if(Keypad.isRowPressed(1) && Keypad.isColumnPressed(1))
  {
    
    digitalWrite(ledPin3,LOW);
    TextToSpeech.say("i have turned it off sir");
   
  }
    
   if(Keypad.isRowPressed(1) && Keypad.isColumnPressed(2))
  {
    
    digitalWrite(ledPin4,HIGH);
    TextToSpeech.say("i have turned it on sir");
   
  }
    if(Keypad.isRowPressed(1) && Keypad.isColumnPressed(3))
  {
    
    digitalWrite(ledPin4,LOW);
    TextToSpeech.say("i have turned it off sir");
   
  }
     
  
  
  
  
  
  
 
}

void myFunction(bool isPhoneRinging ,String phoneNumber)
{
    char* phonenumber = Phone.getNumber();
  
      if(phoneNumber == "+91xxxxxxxxxx")
       {
          /* Turn on the LED. */
          digitalWrite(ledPin1,HIGH);
       }
       else if(phoneNumber == "+91xxxxxxxxx")
        {
          /* Turn on the LED. */
          digitalWrite(ledPin1,LOW);
       }
}

Credits

soumil shah

soumil shah

5 projects • 7 followers
I am someone who “can adapt to any situationt and I transform unexpected obstacles into stepping stones for achievement

Comments