Hey Guys!
I'm a bit new to the arduino, and this forum (this is my first post). I have to say I've been absulutly loving it! I have hit
a bump however in one of my projects and was wondering if you guys could help. For my current project, I copied some of the code from the bitvoicer and LEDs project and slightly modified it to work for a few things around my house such as a light I soldered, my server/pc, and my 3d printer. That was great but now I have this usb cord plugged into my computer all the time, so after doing a bit of research I discovered I could send bitvoicer serial over my LAN network. This is where I'm stuck. I purchased the Ethernet shield today at my Radio Shack but can't figure out how to write the code to run communication to my laptop over my LAN network. Here's my current code:
#include <BitVoicer11.h>
//Instantiates the BitVoicerSerial class
BitVoicerSerial bvSerial = BitVoicerSerial();
//Stores true if the Audio Streaming Calibration tool
//is running
boolean sampleTest = false;
//Stores the data type retrieved by getData()
byte dataType = 0;
//Sets up the pins and default variables
int pc = 12;
int light = 11;
int lightBrightness = 250;
int lightFade = 50;
int printer = 9;
void setup()
{
//Sets the analog reference to external (AREF pin)
//WARNING!!! If anything is conected to the AREF pin,
//this function MUST be called first. Otherwise, it will
//damage the board.
bvSerial.setAnalogReference(BV_EXTERNAL);
//Sets up the microcontroller to perform faster analog reads
//on the specified pin
bvSerial.setAudioInput(0);
//Starts serial communication at 115200 bps
Serial.begin(115200);
//Sets up the pinModes
pinMode(pc, OUTPUT);
pinMode(light, OUTPUT);
pinMode(printer, OUTPUT);
}
void loop()
{
//Captures audio and sends it to BitVoicer if the Audio
//Streaming Calibration Tool is running
if (sampleTest == true)
{
//The value passed to the function is the time
//(in microseconds) that the function has to wait before
//performing the reading. It is used to achieve about
//8000 readings per second.
bvSerial.processAudio(46);
}
//Captures audio and sends it to BitVoicer if the Speech
//Recognition Engine is running
if (bvSerial.engineRunning)
{
//The value passed to the function is the time
//(in microseconds) that the function has to wait before
//performing the reading. It is used to achieve about
//8000 readings per second.
bvSerial.processAudio(46);
}
}
//This function runs every time serial data is available
//in the serial buffer after a loop
void serialEvent()
{
//Reads the serial buffer and stores the received data type
dataType = bvSerial.getData();
//Changes the value of sampleTest if the received data was
//the start/stop sampling command
if (dataType == BV_COMMAND)
sampleTest = bvSerial.cmdData;
//Signals BitVoicer's Speech Recognition Engine to start
//listening to audio streams after the engineRunning status
//was received
if (dataType == BV_STATUS && bvSerial.engineRunning == true)
bvSerial.startStopListening();
//Checks if the data type is the same as the one in the
//Voice Schema
if (dataType == BV_STR)
setLEDs();
}
//Performs the LED changes according to the value in
//bvSerial.strData
void setLEDs()
{
// turns pc on (press power button)
if (bvSerial.strData == "pcHIGH")
{
digitalWrite(pc, HIGH);
delay(200);
digitalWrite(pc, LOW);
delay(200);
digitalWrite(pc, HIGH);
}
//turns pc off (hold power button)
else if (bvSerial.strData == "pcKILL")
{
digitalWrite(pc, LOW);
}
//turn pc off(press button)
else if (bvSerial.strData == "pcLOW")
{
digitalWrite(pc, LOW);
delay(500);
digitalWrite(pc, HIGH);
}
//turns light on
else if (bvSerial.strData == "lightHIGH")
{
digitalWrite(light, HIGH);
lightBrightness = 250;
}
//turns light off
else if (bvSerial.strData == "lightLOW")
{
digitalWrite(light, LOW);
}
//dims light
else if (bvSerial.strData == "lightD")
{
lightBrightness = lightBrightness - lightFade;
analogWrite(light, lightBrightness);
}
//brightens light
else if (bvSerial.strData == "lightB")
{
lightBrightness = lightBrightness + lightFade;
analogWrite(light, lightBrightness);
}
//turns printer relay on
else if (bvSerial.strData == "printerHIGH")
{
digitalWrite(printer, HIGH);
}
//turns printer relay off
else if (bvSerial.strData == "printerLOW")
{
digitalWrite(printer, LOW);
}
}
Thanks guys! Happy Programing!