ahmed ismail
Published © CERN-OHL

Control Christmas Lights with Voice Commands using Arduino

I have hacked into the Christmas LED strips and start controlling it using Arduino and 1Sheeld Voice Recognition.

BeginnerFull instructions provided1 hour4,951

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
1Sheeld
1Sheeld
×1
1Sheeld
1Sheeld
×1
iPhone
Apple iPhone
×1
RobotGeek Relay
RobotGeek Relay
×2
Christmas tree
×1
Christmas LED strip
×1
Jumper wires (generic)
Jumper wires (generic)
×8
9V battery (generic)
9V battery (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Drill Taps
OpenBuilds Drill Taps

Story

Read more

Schematics

Christmas tree lights control schematic

Code

Christmas controlling with voice commands

Arduino
#define CUSTOM_SETTINGS
#define INCLUDE_VOICE_RECOGNIZER_SHIELD

#include <OneSheeld.h>

/* Voice commands set by the user. */
const char poweronCommand[] = "turn on";
const char poweroffCommand[] = "turn off";
const char combinationCommand[] = "combination";
const char wavesCommand[] = "waves";
const char sequentialCommand[] = "sequential";
const char slowCommand[] = "slow";
const char chasingCommand[] = "chasing";
const char fadeCommand[] = "fade";
const char twinkleCommand[] = "twinkle";
const char steadyCommand[] = "steady";


int lamp = 12;
int power = 11;

int counter=0;
int x=0;
int y=0;
int z=0;
int l=0;
int m=0;
int n=0;
int p=0;
int q=0;
int val=0;

void setup()
{
  /* Start Communication. */
  OneSheeld.begin();

   pinMode(lamp,OUTPUT);
    pinMode(power,OUTPUT);
}

void loop () 
{
  /* Check if new command received. */
  if(VoiceRecognition.isNewCommandReceived())
  {
    /* Compare the Poer on command. */
    if(!strcmp(poweronCommand,VoiceRecognition.getLastCommand()))
    {
      digitalWrite(power,LOW);
      counter=0;
    }
/* Compare the Poer off command. */    else if (!strcmp(poweroffCommand,VoiceRecognition.getLastCommand()))
    {
      digitalWrite(power,HIGH);
    }
    /* Compare the combination command. */
    else if (!strcmp(combinationCommand,VoiceRecognition.getLastCommand()))
    {
      x=0-counter;
      if(x<0){
        x+=8;
        }
        for(val=0 ; val<x ; val++){
          mode();
          }
      counter=0;
      
    }
    /* Compare the waves command. */
    else if (!strcmp(wavesCommand,VoiceRecognition.getLastCommand()))
    {
      y=1-counter;
      if(y<0){
        y+=8;
        }
        for(val=0 ; val<y ; val++){
          mode();
          }
      counter=1;
    }
     /* Compare the sequential command. */
    else if (!strcmp(sequentialCommand,VoiceRecognition.getLastCommand()))
    {
      z=2-counter;
      if(z<0){
        z+=8;
        }
        for(val=0 ; val<z ; val++){
          mode();
          }
      counter=2;
    }
    /* Compare the slow command. */
    else if (!strcmp(slowCommand,VoiceRecognition.getLastCommand()))
    {
       l=3-counter;
      if(l<0){
        l+=8;
        }
        for(val=0 ; val<l ; val++){
          mode();
          }
      counter=3;
    }
    /* Compare the chasing command. */
    else if (!strcmp(chasingCommand,VoiceRecognition.getLastCommand()))
    {
      m=4-counter;
      if(m<0){
        m+=8;
        }
        for(val=0 ; val<m ; val++){
          mode();
          }
      counter=4;
    }
    /* Compare the fade command. */
     else if (!strcmp(fadeCommand,VoiceRecognition.getLastCommand()))
    {
       n=5-counter;
      if(n<0){
        n+=8;
        }
        for(val=0 ; val<n ; val++){
          mode();
          }
      counter=5;
    }
     /* Compare the Twinkle command. */
    else if (!strcmp(twinkleCommand,VoiceRecognition.getLastCommand()))
    {
      p=6-counter;
      if(p<0){
        p+=8;
        }
        for(val=0 ; val<p ; val++){
        
         mode();
          }
      counter=6;
    }
      /* Compare the steady command. */
     else if (!strcmp(steadyCommand,VoiceRecognition.getLastCommand()))
    {
       q=7-counter;
      if(q<0){
        q+=8;
        }
        for(val=0 ; val<q ; val++){
          mode();
          }
      counter=7;
    }
  }
}

void mode(){
   digitalWrite(lamp,LOW);
          delay(150);
   digitalWrite(lamp,HIGH);
   delay(150);
  }

Credits

ahmed ismail

ahmed ismail

2 projects • 107 followers
Maker

Comments