Problem with MOVI shield and bluetooth at the same time
hello,
i'm making smart room relays controlled voice audeme movi shield. want option control phone hc-05 bluetooth module can't code work, voice controll works , change code litle bluetooth works. please me.
(note: did not write code on own, parts coppied internet)
here code: (in code voice control works bluetooth doesn't)
#include <movishield.h>
#include <softwareserial.h>
#if defined(arduino_arch_avr) || defined(arduino_arch_pic32)
#endif
movi recognizer(true); // movi object, true enables serial monitor interface, rx , tx can passed parameters alternate communication pins on avr architecture
softwareserial genotronex(10, 11); // rx, tx
int relay1=2; //set relays
int relay2=3;
int relay3=4;
int relay4=5;
int bluetoothdata; // data given computer
void setup() {
pinmode(relay1,output); // set relays output
pinmode(relay2,output);
pinmode(relay3,output);
pinmode(relay4,output);
digitalwrite(relay1,1); //set relays high
digitalwrite(relay2,1);
digitalwrite(relay3,1);
digitalwrite(relay4,1);
genotronex.begin(9600);
recognizer.init(); // initialize movi (waits boot)
recognizer.setsynthesizer(synth_pico); //changes voice of synthesizer
recognizer.callsign("arduino"); //reacts if word
recognizer.addsentence("relay 1 on"); //sentence 1
recognizer.addsentence("relay 1 off"); //sentence 2
recognizer.train(); //train
}
void loop() {
signed int res=recognizer.poll(); // result movi, 0 denotes nothing happened, negative values denote events
if (res==1) { // sentence 1.
digitalwrite(relay2,1); // turn on relay1
recognizer.say("relay 1 on!"); // speak sentence
}
if (res==2) { // sentence 2
digitalwrite(relay1,0); // turn off relay1
recognizer.say("relay 1 off!"); //speak sentence
}
if (genotronex.available()){ //if bluetooth data available
bluetoothdata=genotronex.read(); //read bluetooth data
if(bluetoothdata=='1'){ //if buetooth data 1, turn relay off
digitalwrite(relay1,0);
}
if(bluetoothdata=='2'){ //if buetooth data 2, turn relay on
digitalwrite(relay1,1);
}
if(bluetoothdata=='3'){ //if buetooth data 3, turn relay off
digitalwrite(relay2,0);
}
if(bluetoothdata=='4'){ //if buetooth data 4, turn relay on
digitalwrite(relay2,1);
}
if(bluetoothdata=='5'){ //if buetooth data 5, turn relay off
digitalwrite(relay3,0);
}
if(bluetoothdata=='6'){ //if buetooth data 6, turn relay on
digitalwrite(relay3,1);
}
if(bluetoothdata=='7'){ //if buetooth data 7, turn relay off
digitalwrite(relay4,0);
}
if(bluetoothdata=='8'){ //if buetooth data 8, turn relay on
digitalwrite(relay4,1);
}
}
}
i'm making smart room relays controlled voice audeme movi shield. want option control phone hc-05 bluetooth module can't code work, voice controll works , change code litle bluetooth works. please me.
(note: did not write code on own, parts coppied internet)
here code: (in code voice control works bluetooth doesn't)
#include <movishield.h>
#include <softwareserial.h>
#if defined(arduino_arch_avr) || defined(arduino_arch_pic32)
#endif
movi recognizer(true); // movi object, true enables serial monitor interface, rx , tx can passed parameters alternate communication pins on avr architecture
softwareserial genotronex(10, 11); // rx, tx
int relay1=2; //set relays
int relay2=3;
int relay3=4;
int relay4=5;
int bluetoothdata; // data given computer
void setup() {
pinmode(relay1,output); // set relays output
pinmode(relay2,output);
pinmode(relay3,output);
pinmode(relay4,output);
digitalwrite(relay1,1); //set relays high
digitalwrite(relay2,1);
digitalwrite(relay3,1);
digitalwrite(relay4,1);
genotronex.begin(9600);
recognizer.init(); // initialize movi (waits boot)
recognizer.setsynthesizer(synth_pico); //changes voice of synthesizer
recognizer.callsign("arduino"); //reacts if word
recognizer.addsentence("relay 1 on"); //sentence 1
recognizer.addsentence("relay 1 off"); //sentence 2
recognizer.train(); //train
}
void loop() {
signed int res=recognizer.poll(); // result movi, 0 denotes nothing happened, negative values denote events
if (res==1) { // sentence 1.
digitalwrite(relay2,1); // turn on relay1
recognizer.say("relay 1 on!"); // speak sentence
}
if (res==2) { // sentence 2
digitalwrite(relay1,0); // turn off relay1
recognizer.say("relay 1 off!"); //speak sentence
}
if (genotronex.available()){ //if bluetooth data available
bluetoothdata=genotronex.read(); //read bluetooth data
if(bluetoothdata=='1'){ //if buetooth data 1, turn relay off
digitalwrite(relay1,0);
}
if(bluetoothdata=='2'){ //if buetooth data 2, turn relay on
digitalwrite(relay1,1);
}
if(bluetoothdata=='3'){ //if buetooth data 3, turn relay off
digitalwrite(relay2,0);
}
if(bluetoothdata=='4'){ //if buetooth data 4, turn relay on
digitalwrite(relay2,1);
}
if(bluetoothdata=='5'){ //if buetooth data 5, turn relay off
digitalwrite(relay3,0);
}
if(bluetoothdata=='6'){ //if buetooth data 6, turn relay on
digitalwrite(relay3,1);
}
if(bluetoothdata=='7'){ //if buetooth data 7, turn relay off
digitalwrite(relay4,0);
}
if(bluetoothdata=='8'){ //if buetooth data 8, turn relay on
digitalwrite(relay4,1);
}
}
}
quote
i'm making smart room relays controlled voice audeme movi shield.how arduino communicate shield? if spi shield, can't use pins 10, 11, 12, or 13 (on uno) communicate bluetooth device.
Arduino Forum > Using Arduino > Programming Questions > Problem with MOVI shield and bluetooth at the same time
arduino
Comments
Post a Comment