I have a project by using Elechouse Voice recognition module V3 as a sound recognizer, after my command recognized by VoiceRecognizer V3, i want my bluetooth send some character to Android phone, everything run Okay but when i say send to my recognizer my bluetooth cant send character. Anyone can solve my problem ? I use SoftwareSerial .listen() to separate the working of two serial communication but didnt success,.
Maybe someone ever use this recognizer. I use sample program from this recognizer to modified. this is my program : my configuration pin include inside my program :
#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"
/**
* Connection
* Arduino VoiceRecognitionModule
* 10 -------> TX
* 9 -------> RX
*6 ------> TX(HC-06)
*5 ------> RX(Voltage divider)
*/
VR myVR(10,9); // 10:RX 9:TX, you can choose your favourite pins.
SoftwareSerial myBT(6,5); //BT pin
uint8_t records[7]; // save record
uint8_t buf[64];
int led = 13;
String bt="HELP";
char inbyte;
#define kirimOn (0)
#define ontesLED (1)
#define offtesLED (2)
/**
@brief Print signature, if the character is invisible,
print hexible value instead.
@param buf --> command length
len --> number of parameters
*/
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("]");
}
}
}
/**
@brief Print signature, if the character is invisible,
print hexible value instead.
@param buf --> VR module return value when voice is recognized.
buf[0] --> Group mode(FF: None Group, 0x8n: User, 0x0n:System
buf[1] --> number of record which is recognized.
buf[2] --> Recognizer index(position) value of the recognized record.
buf[3] --> Signature length
buf[4]~buf[n] --> Signature
*/
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\n");
if(buf[3]>0){
printSignature(buf+4, buf[3]);
}
else{
Serial.print("NONE");
}
Serial.println("\r\n");
}
void setup()
{
/** initialize */
myVR.begin(9600);
myBT.begin(9600);
Serial.begin(115200);
Serial.println("Elechouse Voice Recognition V3 Module\r\n send character to android");
pinMode(led, 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)kirimOn) >= 0){
Serial.println("kirim record loaded");
}
if(myVR.load((uint8_t)ontesLED) >= 0){
Serial.println("ontes loaded");
}
if(myVR.load((uint8_t)offtesLED) >= 0){
Serial.println("offtes loaded");
}
}
void loop()
{
int ret;
Serial.write(45);
ret = myVR.recognize(buf, 50);
if(ret>0){
switch(buf[1]){
case kirimOn:
/** turn on LED /program lain untuk kontrol*/
kirimchar();
break;
case ontesLED:
/** turn on LED utk tes*/
digitalWrite(led, HIGH);
break;
case offtesLED:
/** tes led off*/
digitalWrite(led, LOW);
break;
default:
Serial.println("Record function undefined");
break;
}
/** voice recognized */
printVR(buf);
cekAndroid();
}
}
void cekAndroid(){
if (myBT.available() > 0)
{
inbyte = myBT.read();
if (inbyte == '0')
{
//LED off
digitalWrite(led, LOW);
}
else if (inbyte == '1')
{
//LED on
digitalWrite(led, HIGH);
}
}
}
void kirimchar(){
myBT.listen();
myBT.print(bt);
myBT.println();
delay(10);
}