Go Down

Topic: Voice Recognition Module programming issue (Read 4 times) previous topic - next topic

PaulS

Your first code was reading from a software serial port and writing to a hardware serial port. This last code has you reading from the hardware serial port. Did you move the VR module? Why?

Rustie0125

No The code I posted last is the original code as from the module supplier, the code i posted first is my code modified to work on software serial so i can view serial monitor . but when i first tried with the original code it also didn't work
He who does not try ,does not fail ,does not learn not to fail again http://powerduino.blogspot.com/

PaulS

I don't understand what you are doing. If you didn't move the VR module to the hardware serial pins, how can you expect to read from it?

With the hardware connected to the software serial pins, what are you seeing in the Serial Monitor application?

Rustie0125

I think we miss understood each other, at first i tried the original code form the supplier which forced me to disconnect the VR module each time i uploaded the code so i added the software serial so i didnt have to anymore , so i moved the pins to the 2,and 3 for software serial. now when i speak into the VR module i get what i expect in the serial monitor . when i say any of the given 5 words i get "Result: 11" "Result :12" exc. so the software serial read works fine . its just the comparison that doesn't seem to work.

here is the link to the manual and product page (scross down)
http://www.ebay.com/itm/Voice-Recognition-Module-Arduino-Compatible-Control-your-devices-by-voice-/140613022031?pt=LH_DefaultDomain_0&hash=item20bd30714f 

http://www.elechouse.com/elechouse/images/product/Voice%20Recognition%20Module/Manual.pdf
He who does not try ,does not fail ,does not learn not to fail again http://powerduino.blogspot.com/

PaulS

Quote
so the software serial read works fine . its just the comparison that doesn't seem to work.

Show the Serial Monitor output, please.

The reason that the comparison doesn't work is because you are comparing the wrong things. What the code you first posted compares is the number of characters written to the serial monitor to some values. None of them match, of course. because each call to Serial.write(), Serial.println(), or Serial.print() with an int writes or prints different numbers of characters, depending on the value being printed. "1" has one character. "102<cr><lf>" is 5 characters. None of the values returned by the serial output methods has anything to do with the value that was put on the port - only the number of characters involved.

What it appears that you need to do is to read AND STORE data from the software serial port, until an end of packet marker (what that would be requires some discovery on your part - possibly a <cr> or and <lf>) and then compare that stored value to some known strings, using strcmp().

In the middle of the 3rd page, there is mention of compact mode. In this mode, the device will return 0x11 or 0x12 corresponding to "Result: 11" or "Result: 12". Dealing with one byte will be far easier than dealing with a string.

I'd look into what it takes to get the module into compact mode.

Go Up