Oguz Salar
Published

Voice Assistant Using A Smart Phone And 1Sheeld

You can make FRIDAY, that can make calls, tell you the temperature, turn things on or off and even take pictures.

BeginnerFull instructions provided3,010

Things used in this project

Story

Read more

Schematics

FGLUB4BIDUR4PP3.LARGE.jpg

Code

Untitled file

Arduino
//including the necessary 1sheeld shields and 1Sheeld itself
#define CUSTOM_SETTINGS
#define INCLUDE_TEXT_TO_SPEECH_SHIELD
#define INCLUDE_VOICE_RECOGNIZER_SHIELD
#define CUSTOM_SETTINGS
#define INCLUDE_PHONE_SHIELD
#define INCLUDE_BUZZER_SHIELD
#define INCLUDE_CAMERA_SHIELD
#include <OneSheeld.h>

//setting the variables and commands
const int pinTemp = A0;
float temperature;
int B=3975;                
float resistance;
//I had some difficulties with telling the exact word so i altered the commands a bit
const char one[]="temperature";
const char two[]="how are you";
const char three[]="what is this box";
const char four[]="light";
const char five[]="of";
const char six[]="kol";
const char seven[]="make noise";
const char nine[]="over";
const char ten[]="bright lights";
const char eleven[]="picture";

void setup()
{
  OneSheeld.begin();    //defining the leds and setting them as outputs
  pinMode(13,OUTPUT);
  pinMode(12,OUTPUT);
}

void loop()  //comand functions occur from this line
{  
   if(VoiceRecognition.isNewCommandReceived())
   {
    
//temperature
     if(!strcmp(one,VoiceRecognition.getLastCommand()))
         {
      int val = analogRead(pinTemp);
      resistance=(float)(1023-val)*10000/val;
      temperature=1/(log(resistance/10000)/B+1/298.15)-273.15;
      int n= temperature * -1 ;
      String temp="The Temperature is :";
      temp += String(n);
      temp +="degree celcius, sir";
      TextToSpeech.say(temp);
         }

//how are you
     else if(!strcmp(two,VoiceRecognition.getLastCommand()))
         {
          TextToSpeech.say("Like a charm sir,");
          delay(1000);
          TextToSpeech.say("you");
         }
         
//self introduction    
     else if(!strcmp(three,VoiceRecognition.getLastCommand()))
         {
         TextToSpeech.say("this is The Beacon project that you made, sir");
         }
   
//LED pin 13
     else if(!strcmp(four,VoiceRecognition.getLastCommand()))
         {
         digitalWrite(13, HIGH);
         }

//LED pin 13 off     
     else if(!strcmp(five,VoiceRecognition.getLastCommand()))
         {
         digitalWrite(13, LOW);
         }

//making a call
     else if(!strcmp(six,VoiceRecognition.getLastCommand()))
         {
         Phone.call("01234567890");
         }

//make noise
     else if(!strcmp(seven,VoiceRecognition.getLastCommand()))
         {
         Buzzer.buzzOn();
         delay(5000);
         Buzzer.buzzOff();
         }       

//LED pin 12
     else if(!strcmp(nine,VoiceRecognition.getLastCommand()))
         {
         digitalWrite(12, HIGH);
         }
     
//LED pin 12 off    
     else if(!strcmp(ten,VoiceRecognition.getLastCommand()))
         {
         digitalWrite(12, LOW);
         }

//taking a picture
     else if(!strcmp(eleven,VoiceRecognition.getLastCommand())) 
         {
         Camera.setQuality(HIGH_QUALITY);
         Camera.setFlash(AUTO);
         Camera.rearCapture();
         }
        }
       }

Codebender

Credits

Oguz Salar

Oguz Salar

1 project • 4 followers
just a Turkish maker

Comments