Hello Guys I have confusion in my project, I have designed A code which working on perfect only in Arduino NANO without wireless, now I want to control voice controlled Car via voice recognition Module 3.1, I have two Boards one is Arduino UNO, which is Transmitting side, and Aruino Nano which is receiver side, so please let me guide about this problem. the working code as following:
/**
- @file vr_sample_control_led.ino
- @author JiapengLi
-
@brief This file provides a demostration on
how to control led by using VoiceRecognitionModule
-
@note:
voice control led
- @section HISTORY
2013/06/13 Initial version.
*/
#include <SoftwareSerial.h>
#include "VoiceRecognitionV3.h"
/**
Connection
Arduino VoiceRecognitionModule
2 -------> TX
3 -------> RX
*/
VR myVR(2,3); // 2:RX 3:TX, you can choose your favourite pins.
uint8_t records[7]; // save record
uint8_t buf[64];
int m1_f = A0;
int m1_b = A1;
int m2_f = A2;
int m2_b = A3;
#define Stop (1)
#define Forward (5)
#define Backward (2)
#define Left (3)
#define Right (4)
/**
@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_>0x19 && buf<0x7F){_
_ Serial.write(buf*);
}
else{
Serial.print("[");
Serial.print(buf, 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");
if(buf[3]>0){
printSignature(buf+4, buf[3]);
}
else{
Serial.print("NONE");
}
Serial.println("\r\n");
}
void setup()
{
/** initialize /
myVR.begin(9600);_
* Serial.begin(115200);*
* Serial.println("Elechouse Voice Recognition V3 Module\r\nControl LED sample");*
* pinMode(m1_f, OUTPUT);
pinMode(m1_b, OUTPUT);
pinMode(m2_f, OUTPUT);
pinMode(m2_b, 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)Stop >= 0)){
_ Serial.println("Stop loaded");
}*_
* if(myVR.load((uint8_t)Forward) >= 0){
_ Serial.println(" Forward loaded");*_
* }*
* if(myVR.load((uint8_t)Backward) >= 0){
_ Serial.println("Backward loaded");
}*_
* if(myVR.load((uint8_t)Right) >= 0){
_ Serial.println("Right loaded");
}*_
* if(myVR.load((uint8_t)Left) >= 0){
_ Serial.println("Left loaded");
}
}
void loop()
{
int ret;
ret = myVR.recognize(buf, 50);
if(ret>0){
switch(buf[1]){
case Stop:_
digitalWrite(m1_f, LOW); // STOP*
* digitalWrite(m1_b, LOW); // STOP*
* digitalWrite(m2_f, LOW); // STOP*
* digitalWrite(m2_b, LOW); // STOP*
* break;*
* case Forward:*
* digitalWrite(m1_f, LOW); // STOP*
* digitalWrite(m1_b, LOW); // STOP*
* digitalWrite(m2_f, LOW); // STOP*
* digitalWrite(m2_b, HIGH); // MOTOR WILL ON TO FORWARD
_ break;
case Backward:_
digitalWrite(m1_f, LOW); // STOP*
* digitalWrite(m1_b, HIGH); // MOTOR WILL ON TO BACKWARD*
* digitalWrite(m2_f, LOW); // STOP*
* digitalWrite(m2_b, LOW); // STOP*
* break;*
* case Left:*
* digitalWrite(m1_f, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(m1_b, LOW); // turn the LED on (HIGH is the voltage level)
digitalWrite(m2_f, HIGH); // MOTOR WILL ON LEFT SIDE*
* digitalWrite(m2_b, LOW); // turn the LED on (HIGH is the voltage level)
_ break;
case Right:_
digitalWrite(m1_f, HIGH); // MOTOR WILL ON RIGHT SIDE*
* digitalWrite(m1_b, LOW); // STOP*
* digitalWrite(m2_f, LOW); // STOP*
* digitalWrite(m2_b, LOW); //STOP*
* break;*
* default:*
* Serial.println("Record function undefined");*
* break;*
* }*
_ /** voice recognized /
printVR(buf);
}
}*_