okay thank you Paul.
here is the code again formatted properly.
#include <SoftwareSerial.h> // use for software serial tobe able to monitor serial output will speaking into the VR module
SoftwareSerial mySerial(2, 3); // RX, TX software serial pin selection
// Variables declaration
int Pin;
int redPin = 9; // R petal on RGB LED module connected to digital pin 11
int greenPin = 8; // G petal on RGB LED module connected to digital pin 9
int bluePin = 7; // B petal on RGB LED module connected to digital pin 10
int barPin = 11;
int lightPin = 12;
int garagePin = 10;
int musicPin = 6;
int strobePin = 5;
byte com = 0; // Reply from voice recognition
// Program Setup
void setup()
{
// Serial communication Speed
Serial.begin(38400);
mySerial.begin(38400);
// PinMode declaration
pinMode(redPin, OUTPUT); // sets the redPin to be an output
pinMode(greenPin, OUTPUT); // sets the greenPin to be an output
pinMode(bluePin, OUTPUT); // sets the bluePin to be an output
pinMode(Pin,OUTPUT);
//Device Setup via AT commands
mySerial.write(0xAA);
mySerial.write(0x37); // Switch module into compact mode
delay(500);
mySerial.write(0xAA);
mySerial.write(0x21); // Import Group1 of 5 words
delay(1000);
Serial.println(" Please say which environment you would like to control");
Serial.println(" Jarvis,Lounge,Garden,Bar ");
}
// Program starts
void loop()
{
while(mySerial.available())
{
com = mySerial.read();
Serial.println(com,HEX);
switch(com)
/////////////////////////////////////////////////////////////////////////// Rooms set
{
case 0x11:
Serial.println("Jarvis");
jarvis();
break;
case 0x12:
Serial.println("Lounge");
lounge();
break;
case 0x13:
Serial.println("Garden");
garden();
break;
case 0x14:
Serial.println("All off");
all_off();
break;
case 0x15:
Serial.println("Bar");
barGroup(); // turn the RGB LED off
break;
/////////////////////////////////////////////////////////////////////// Appliance set
case 0x31:
Serial.println("BAR");
Pin = barPin;
CtrlGroup();
break;
case 0x32:
Serial.println("lights");
Pin = lightPin;
CtrlGroup();
break;
case 0x33:
Serial.println("Garage");
Pin = garagePin;
CtrlGroup();
break;
case 0x34:
Serial.println("Music");
Pin = musicPin;
CtrlGroup();
break;
case 0x35:
Serial.println("Strobe");
Pin = strobePin;
CtrlGroup();
break;
/////////////////////////////////////////////////////////////////////// Control set
case 0x21:
Serial.println("started Device");
Start();
break;
case 0x22:
Serial.println("off");
off();
break;
case 0x23:
Serial.println("dim");
Dim();
break;
case 0x24:
Serial.println("stop");
Stop();
break;
case 0x25:
Serial.println("all off");
off();
break;
}
}
}
//////////////////////////////////////////////Group 1 void functions/////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
void jarvis()//0x11
{
mySerial.write(0xAA);
mySerial.write(0x23); // Import Group3 of 5 words
delay(1000);
Serial.println("jarvis selected");
while(mySerial.available())
{
com = mySerial.read();
Serial.print("voice results:");
Serial.println(com,HEX);
Serial.println(" Please say which Appliance you would like to control");
Serial.println("Options: Lights, BAR lights,Garage door, Music, Strobe ");
}
}
void lounge()//0x12
{
mySerial.write(0xAA);
mySerial.write(0x23); // Import Group3 of 5 words
delay(1000);
Serial.println("lounge selected");
while(mySerial.available())
{
com = mySerial.read();
Serial.print("voice results:");
Serial.println(com,HEX);
Serial.println(" Please say which Appliance you would like to control");
Serial.println("Options: Lights, Music, Strobe ");
}
}
void garden()
{
mySerial.write(0xAA);
mySerial.write(0x23); // Import Group3 of 5 words
delay(1000);
Serial.println("Garden selected");
while(mySerial.available())
{
com = mySerial.read();
Serial.print("voice results:");
Serial.println(com,HEX);
Serial.println(" Please say which Appliance you would like to control");
Serial.println("Options: Lights,pool light,Garage door, Music ");
}
}
void all_off()
{
mySerial.write(0xAA);
mySerial.write(0x23); // Import Group3 of 5 words
delay(1000);
Serial.println("all off ");
while(mySerial.available())
{
com = mySerial.read();
Serial.print("voice results:");
Serial.println(com,HEX);
}
}
void barGroup()
{
mySerial.write(0xAA);
mySerial.write(0x23); // Import Group3 of 5 words
delay(1000);
Serial.println("bar Selected");
while(mySerial.available())
{
com = mySerial.read();
Serial.print("voice results:");
Serial.println(com,HEX);
Serial.println(" Please say which Appliance you would like to control");
Serial.println("Options: Lights, Pool table lights,Garage door, Music, Strobe ");
}
}
/////////////////////////////////////////////////////////////////Group 2 void functions /////////////////////////////////////////////
////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////
void CtrlGroup()
{
mySerial.write(0xAA);
mySerial.write(0x22); // Import Group2 of 5 words
delay(1000);
Serial.println("controls active");
while(mySerial.available())
{
com = mySerial.read();
Serial.print("voice results:");
Serial.println(com,HEX);
}
}
//////////////////////////////////////////////////////////////////////Group 3 void functions ////////////////////////////////////////
////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////
void Start()//0x21
{
Serial.print("output pin :");
Serial.println(Pin);
digitalWrite(Pin,HIGH);
}
void off()//0x23 and 0x25
{
digitalWrite(Pin,LOW);
mySerial.write(0xAA);
mySerial.write(0x21); // Import Group1 of 5 words
delay(500);
}
void Dim()//0x24
{
analogWrite(Pin,150);// object to be dimmed must be connected to analog pin
}
void Stop()//0x22
{
digitalWrite(Pin,LOW);
}