I have connected a bluetooth module(HC-06) and a voice recognition shield(EasyVR) on an arduino UNO.
I’m using 2 arduinos, one is for EasyVR(voice recognition) + bluetooth recieve signal and another arduino is for bluetooth sending signal by switch(botton)
This is a design proposal.
I have successed each operations(bluetooth and EasyVR), but after combining two codes it doesn’t work… (Voice recognition have successed.)
1.Is it unable to operate two operations simultaneously?
- What is the problem of my code?
It uploaded well but doesn’t work.
#include “Arduino.h”
#define BUTTON_PIN 2
#include “SoftwareSerial.h”
#include “EasyVR.h”
#include “EasyVRBridge.h”
SoftwareSerial port(12,13);
SoftwareSerial BT(8,9);
EasyVR easyvr(port);
EasyVRBridge bridge;
volatile int state = LOW;
uint8_t train = 0;
char name[32];
void setup()
{
pinMode(BUTTON_PIN, INPUT_PULLUP);
if (bridge.check())
{
cli();
bridge.loop(0, 1, 12, 13);
}
Serial.begin(9600);
port.begin(9600);
BT.begin(9600);
attachInterrupt(0, bluetooth, CHANGE);
//attachInterrupt(1, voice, RISING);
if (!easyvr.detect())
{
Serial.println(“EasyVR not detected!”);
for (;;);
}
easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println(“EasyVR detected!”);
easyvr.setTimeout(5);
easyvr.setLanguage(EasyVR::ENGLISH);
}
void loop(){
int idx_cmd;
easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println(“Say a name in Group 1”);
easyvr.recognizeCommand(1);
while (!easyvr.hasFinished());
delay(3000);
idx_cmd = easyvr.getCommand();
if (idx_cmd >= 0)
{
Serial.print("Name: ");
if (easyvr.dumpCommand(1, idx_cmd, name, train))
Serial.println(name);
else
Serial.println();
easyvr.setPinOutput(EasyVR::IO1, HIGH);
easyvr.setPinOutput(EasyVR::IO2, HIGH);
delay(3000);
easyvr.setPinOutput(EasyVR::IO1, LOW);
easyvr.setPinOutput(EasyVR::IO2, LOW);
}
}
void bluetooth(){
// Serial.print(“bluetooth”);
static unsigned long lastDebounceTime = 0;
unsigned long debounceTime = millis();
if(BT.available())
{
// Serial.print(“OK”);
int sw=BT.read();
if(sw==‘0’){
easyvr.setPinOutput(EasyVR::IO1, HIGH);
}
if(debounceTime - lastDebounceTime > 200){
BT==!BT;
Serial.print(“Fail”);
}
lastDebounceTime = debounceTime;
}
}
/*
void bluetooth(){
int idx_cmd;
easyvr.setPinOutput(EasyVR::IO1, LOW);
Serial.println(“Say a name in Group 1”);
easyvr.recognizeCommand(1);
while (!easyvr.hasFinished());
idx_cmd = easyvr.getCommand();
if (idx_cmd >= 0)
{
Serial.print(“Voice”);
if (easyvr.dumpCommand(1, idx_cmd, name, train))
Serial.println(name);
easyvr.setPinOutput(EasyVR::IO1, HIGH);
easyvr.setPinOutput(EasyVR::IO2, HIGH);
delay(3000);
easyvr.setPinOutput(EasyVR::IO1, LOW);
easyvr.setPinOutput(EasyVR::IO2, LOW);
}
}
*/