Voice controlled Car

My connections appear to be correct. Please guide whether the code is incorrect. If the code is correct, guide on possible checkings please

030-Voice-Controlled-Arduino-Robot-Car.ino (3.88 KB)

Why don't you start by explaining what's (not-) happening when you try to run the car?

Am I being even denser than usual, or is that "voice activation" just a String like "*turn on light" typed in over Serial?

Where's does the actual "voice activation" come in? Or is that a separate box that recognises what you say and then sends the "*turn on light" etc in on Serial?

Let me explain in brief..We are school students..Code is borrowed..Our requirement is that 'we would say.."forward" over a android mobile app voice recogniser and the car should move forward as said in the code and so on. App is properly connecting my HC-05 bluetooth module and it is also recognising my voice but car is not moving. We checked the motors and they are ok. All individual components are working properly. Right side motors of 4 wheel car is connected to M1 and M2 and left side to M3 and M4, motor driver shield L293D. Blootooth TX is connected to 0 and RX to 1 in Arduino. Is this right?

That's it. Servo is used just for turning right and left.

Have I explained enough.

Do you know for an absolute fact those command Strings "*go back" or whatever are arriving at the Arduino?

You could mimic BT by just typing those commands into the monitor I reckon. At least you would know they are arriving.

If I were you I would use eg the built in led to come on when it's supposed to go forward and then off for back.

Or move the BT off the Serial to a soft serial port, and use Serial for proper de-bug prints so that every "if" sends a print to show where it is.

Right now, seems to me that if the motors aren't responding it could be that the command Strings aren't arriving.

Why don't you re-instate the //'d out 2x LEDs and the buzzer, at least see if the led and buzzer commands are working?

You are right. The commands are not arriving at Arduino as LEDs and buzzer too are not responding. And I am a student and I do not understand that suggestions of seeing in the monitor. Can you modify the code accordingly and send please. Would be grateful for the same.

ansridhar:
I do not understand that suggestions of seeing in the monitor. Can you modify the code accordingly and send please. Would be grateful for the same.

I had actually just done that and your reply arrived before I sent the below:

I don't have the AF library so I zapped all that stuff from your code and tested it from the Serial monitor. Just type for example *go ahead in the serial monitor with no line ending; see pic at bottom of this post.

I made these changes:

if (voice.length() > 0) {
    Serial.println(voice); //<<<<<<<<<<<<<<<<<<<<<<<<
    if (voice == "*go ahead") {
      Serial.println("in go ahead"); //<<<<<<<<<<<<<<<<<<<<<<<<
      forward_car();
    }

..
..

void forward_car()
{
  Serial.println("forward"); // <<<<<<<<<<<<<<
}

And when I typed *go ahead in the monitor, I got:

*go ahead
in go ahead
forward

That tells me the code accepts data from Serial, and that at least the one string takes us to the right part of the code. (although of course I can't test the BT, just the monitor.) You should do something similar.... test it from the monitor. First, check you get the right stuff printed and see if the motors run.

If the right Strings are arriving having been typed in, and the motors don't work (although the code goes to the right place) that tells you about the hardware. If the motors do work with typed in commands, but not with BT, that tells you something about the BT.

You need to adopt some systematic fault finding approach, to eliminate each possible cause one by one.

If you're not familiar with the parts of the monitor, see this pic below which I saw in the forum the other day, by our fellow member GolamMostafa:

SerialMonitor.png

By the way, I re-instated the led on/off commands that were //'d out and they work from the monitor.

Worked and adopted fault finding approach. When I used a different app (without voice), motors ran with using BT. But with voice they didn't. I feel BT is not able to transmit voice back to Arduino and instruct motors to run. Do you have a simple "BT check with voice" code, which I can test? That will help me eliminate BT as a fault.

ansridhar:
Worked and adopted fault finding approach. When I used a different app (without voice), motors ran with using BT. But with voice they didn't.

Excellent: so that tells you the Arduino and the motors are good, and that the Arduino is capable of "interpreting" the input strings.

ansridhar:
Do you have a simple "BT check with voice" code.

No I don't but.....

ansridhar:
I feel BT is not able to transmit voice back to Arduino

Surely it can't. The BT doesn't "transmit voice", and even if it could that's not what the Arduino is looking for. The Arduino is looking for characters in a row such as *turn on light through Serial and we both proved that. I proved it works when typed in from the monitor, and you proved it worked over BT with a different app. So your BT voice app surely needs to send *turn on light etc in response to your voice, and not "transmit voice back to Arduino".

But at least we know the Arduino hardware and code is doing what it's supposed to do: listen to Serial for certain commands, and when it gets them it works as advertised.

Replacing BT - only choice?

You need to know EXACTLY what your Android app is sending. Maybe you need to replace that app. Or if it is sending anything useful but not what you think then you need to change the Arduino code to use whatever it's actually sending.

Steve

I have no idea: no experience with BT apps. Someone else here might have some ideas, but I'd say it's beyond the expectation of an Arduino forum to advise on creating a string-from-voice on another device.

My expertise here was to help you prove the Arduino side is ok, provided there's a means of getting the *turn on light etc commands in. And we've proved that if you can get the String into the Arduino through Serial it works: I have nfc how to make such a string (other than typing it in like I did in the monitor to test the Arduino side.)

So I'm sorry: glad to have helped so far, but that's all I can advise on.

slipstick:
You need to know EXACTLY what your Android app is sending.

Which is why I put this in the code a while back, to see what's actually arriving:

if (voice.length() > 0) {
    Serial.println(voice); //<<<<<<<<<<<<<<<<<<<<<<<<

Its nice of you to guide till the end. Will replace BT tomorrow. I ran one simple BT voice code which also didnt work. Thanks for the help. Will close this chat here unless you would want to give any new tip

I know you have the BT on the same pins as the monitor is using through the usb, but I suspect if you do a Serial.print it should still get to the monitor with BT on.

So if you do this:

 if (voice.length() > 0) {
    Serial.println(voice); //<<<<<<<<<<<<<<<<<<<<<<<<

... what does it echo back when you send in a command from BT?

I verified that with BT on Uno pins 0 and 1 (like you must have since your BT is on Serial), commands from BT terminal on my phone to an HC-06 BT module do echo to the serial monitor.

So please put that line of code in your sketch, and whatever you send from your BT app to the Arduino will echo to the monitor. That way you can a) verify that the app you know works (the non-voice one) is indeed sending *turn lights on or whatever (which we already know since it works, but nice to see it echo anyway) and b) see whatever the app which doesn't work (the voice one) is actually sending, if anything. (But do "a" first so that if "b" sends nothing you will already know that the echo does actually work.)

I also in the process re-verified what you already proved earlier: *turn on light typed on BT terminal on my phone, does actually turn the leds on as expected. (Previously I had only tested that from the serial monitor.)