Hi everyone, it is Chrystal with the update.

 

First of all, my Dad told me that the temperature will be voice controlled, AFTER I GOT IT WORKING!!! So I spent all day today (after school) and added it into the voice program, haha to him, it works. He has no idea yet as he is working on the wooden clock. Below is the Arduino script that is used for the whole voice control, my part is in red so it stands out. I drew a quick picture of how it works, I couldn't get a picture without him finding out... I will tell him after this is posted.

 

#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"


VR myVR(2,3); 

uint8_t records[7];
uint8_t buf[64];

int led = 13;
int Hotter = 8;
int Colder = 9;

#define Light (0)
#define Dark (1)
#define Hot (2)
#define Cold (3)
#define Sleep (4)
#define Timer (5)
#define Stop (6)


void printSignature(uint8_t *buf, int len)
{
  int i;
  for(i=0; i<len; i++){
    if(buf[i]>0x19 && buf[i]<0x7F){
      Serial.write(buf[i]);
    }
    else{
      Serial.print("[");
      Serial.print(buf[i], HEX);
      Serial.print("]");
    }
  }
}


*/
void printVR(uint8_t *buf)
{
  Serial.println("VR Index\tGroup\tRecordNum\tSignature");

  Serial.print(buf[2], DEC);
  Serial.print("\t\t");

  if(buf[0] == 0xFF){
    Serial.print("NONE");
  }
  else if(buf[0]&0x80){
    Serial.print("UG ");
    Serial.print(buf[0]&(~0x80), DEC);
  }
  else{
    Serial.print("SG ");
    Serial.print(buf[0], DEC);
  }
  Serial.print("\t");

  Serial.print(buf[1], DEC);
  Serial.print("\t\t");
  if(buf[3]>0){
    printSignature(buf+4, buf[3]);
  }
  else{
    Serial.print("NONE");
  }
  Serial.println("\r\n");
}

void setup()
{

  myVR.begin(9600);
 
  Serial.begin(115200);
  Serial.println("Elechouse Voice Recognition V3 Module\r\nControl Clock");
 
  pinMode(led, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
   
  if(myVR.clear() == 0){
    Serial.println("Recognizer cleared.");
  }else{
    Serial.println("Not find VoiceRecognitionModule.");
    Serial.println("Please check connection and restart Arduino.");
    while(1);
  }
 
    if(myVR.load((uint8_t)Light) >= 0)
      {
        Serial.println("Light loaded");
      }
 
    if(myVR.load((uint8_t)Dark) >= 0)
      {
        Serial.println("Dark loaded");
      }
     
    if(myVR.load((uint8_t)Hot) >= 0)
      {
         Serial.println("Hot loaded");
      }
 
    if(myVR.load((uint8_t)Cold) >= 0)
      {
        Serial.println("Cold loaded");
     
     
    if(myVR.load((uint8_t)Sleep) >= 0)
      {
      Serial.println("Sleep loaded");
      }
 
    if(myVR.load((uint8_t)Timer) >= 0)
      {
        Serial.println("Timer loaded");
      }
     
    if(myVR.load((uint8_t)Stop) >= 0)
      {
        Serial.println("Stop loaded");
      }

}

 

void loop()
{
  int ret;
  ret = myVR.recognize(buf, 50);
  if(ret>0){
    switch(buf[1]){
      case Light:
        /** turn on LED */
        digitalWrite(7, LOW);
        digitalWrite(led, HIGH);
        break;
       
      case Dark:
        /** turn off LED*/
        digitalWrite(led, LOW);
        digitalWrite(7, LOW);
        break;
       
      case Hot:
        /** turn up temperature */
          digitalWrite(Hotter, HIGH);
          delay(1000);
          digitalWrite(Hotter, LOW);
        break;
       
      case Cold:
        /** turn down temperature*/       
          digitalWrite(Colder, HIGH);
          delay(1000);
          digitalWrite(Colder, LOW);       
        break;

 

     case Sleep:
        /** turn down lights */
        digitalWrite(led, LOW);
        digitalWrite(7, HIGH);
        break;
      case Timer:
        /** set 5 minute timer*/
        /** To be determined*/
        break;
      case Stop:
        /** Stop all*/
        digitalWrite(led, LOW);
        digitalWrite(7, LOW);
       
        break;   
      default:
        Serial.println("Record function undefined");
        break;
    }

    printVR(buf);
  }
}

 

As you can see I kind of copied what Dad was doing but I got it to work on my own!!

 

Thermostat.jpg

 

So how this works is when you say "Hot" the motor turns clockwise a bit upping the temperature (I need to calibrate this) and when you say "Cold" the motor turns counter clockwise and turns the temperature down. I feel this was a bit simple for what could have been thought up to use, but it works. I also added 2 LED lights, 1 red and 1 green/blue. The red light turns on (Briefly) when the temperature is raised and the green/blue turns on (Briefly) when the temperature is lowered. This is a visual way to know the command was recognised.

 

Thank you for reading,

 

Chrystal Winhold

 

P.S. My picture is better then my Dad's!!!