Operating arduino process simultaneously

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?

  1. 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);

}
}
*/

You can do many things at once, except if an external library or hardware blocks execution (timeouts etc). There are tutorials for this. Check posts glued to top of forum.

See Useful Links ->
Blink without delay
How to do several things at a time

for general multitasking with an Arduino

1.Is it unable to operate two operations simultaneously?

A single processor system can never do two operations simultaneously.

  1. What is the problem of my code?

First, it is not posted correctly. There are stickies at the top of the forum that you were supposed to read BEFORE posting here. Go read them now, and fix your post.

Second, the commented out functions no nothing. You should have DELETED them.

Third, the indenting is horrid. You should have used Tools + Auto Format before embarrassing yourself posting that crap.

Finally, the problem is that your expectations are wrong. The code is working fine. What you need to do is describe exactly what code, and what you expect, so we can help you adjust your expectations.