Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
TMP-23-390
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
TMP-23-390
TMP-23-390
Commits
bd0ec3ef
Commit
bd0ec3ef
authored
Oct 08, 2023
by
Vidura Randika
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delete Main Code
parent
01c3262e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
130 deletions
+0
-130
Main Code
Main Code
+0
-130
No files found.
Main Code
deleted
100644 → 0
View file @
01c3262e
#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 led = 13;
#define onRecord (2)
#define offRecord (3)
/**
@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");
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(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)onRecord) >= 0){
Serial.println("onRecord loaded");
}
if(myVR.load((uint8_t)offRecord) >= 0){
Serial.println("offRecord loaded");
}
}
void loop()
{
int ret;
ret = myVR.recognize(buf, 50);
if(ret>0){
switch(buf[1]){
case onRecord:
/** turn on LED */
digitalWrite(led, HIGH);
break;
case offRecord:
/** turn off LED*/
digitalWrite(led, LOW);
break;
default:
Serial.println("Record function undefined");
break;
}
/** voice recognized */
printVR(buf);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment