9V DC motor doesnt work when i want to control it with my bluetooth modul

Hey everyone!
I wanted to control my dc motor through bluetooth today. For this i used L293D driver like in the picture that i attached. I made an easy code for this and it worked. It went to both directions and stopped, no problem.
After that, i attached my bluetooth modul to the board and controlled the motor with my phone. It worked for a while, I could control the speed of the motor and stop it. I wanted to do some more things so i plugged my usb out and write some more things in my code. I plugged my usb in and my dc motor didnt work anymore with my bluetooth. The bluetooth is okay(i wrote some messages to the serial port with it). If i dont use bluetooth, just write an easy code for the motor itself that is working too.
So my question is: Is it some supply problem? If you dont think so, what else could cause this problem? I have read that it is not recommended to have the same supply for dc motor and the rest of the arduino, but i found many webpages that use just one power supply( like the page where is the image from)

const int motorIn1 = 9;  
const int motorIn2 = 10;  

int mv;

void setup()



void loop()

if (Serial.available()>0)
    char data = Serial.read();
    mv = (int)data;
    Serial.print("  ");
    switch (mv) {
    case  49: Serial.println("aa");   analogWrite(motorIn1,170); analogWrite(motorIn2,0); 
    case  50: Serial.println("bb");  analogWrite(motorIn1,0); analogWrite(motorIn2,0); 
    case  51: ;Serial.println("cc"); analogWrite(motorIn1,220); analogWrite(motorIn2,0);
    case  52: ;Serial.println("dd"); analogWrite(motorIn1,10); analogWrite(motorIn2,0);


Here is my code too, but the problem is something else, since it worked for a while

The Arduino is not a power supply, and the 5V output cannot safely provide enough current to run motors or servos. Nor can a laptop.

Use a separate power supply for the motor/driver as electrical noise generated by the motor will often cause the Arduino to malfunction. Don't forget to connect the grounds.

i found many webpages that use just one power supply( like the page where is the image from)

Ignore those. They are all written by people who have no idea what they are doing, but managed to get something to work, at least once.

I tried to use a 9v battery as a power supply for the board and gave power to the arduino through usb, but it still doesnt work. The bluetooth led blinked so i could give power from the battery(and connect to the modul) but the motor didnt do anything. I uploaded the “easy code” for the motor and that works. So my problem is still the same.
Edit: I used only the usb as a power supply for the easy code, i should have tried that with the battery. By easy code i mean a code that makes the motor working at a certain speed then it stops and it starts again. I turned off my pc tomorrow i will try some other things but i dont really have an idea
Thanks for your answer tho

It looks like you are reading the bluetooth with a hardware serial connection which is fine if you disconnect the module when you dowload code to the board over usb.

Does you sketch work to control the motor correctly when you use the serial monitor to enter the commands instead of bluetooth?

A 9V block battery cannot supply enough power for a motor. They are for smoke alarms.

Use a 9 to 12V AA battery pack or power brick.

Okay so today the code without the bluetooth isnt working either. If i give direct power to the motor it works, so yeah i didnt ruin it yet. If my supplies are not enough, why did the following code work yesterday?

const int motorIn1= 9;  
const int motorIn2= 10; 

void setup()
  pinMode(motorIn1,OUTPUT);  //initialize the motorIn1 pin as output 
  pinMode(motorIn2,OUTPUT);  //initialize the motorIn2 pin as output 

void loop()

It shouldnt had worked yesterday either then.

Can i use the 9V battery for a dc motor that has less than 9V?
Or its not enoguh for any motor at all?

Can i use the 9V battery for a dc motor that has less than 9V?
Or its not enough for any motor at all?

The little 9v PP3 batteries are not good for any motor use. Don't use them. They won't even power a bare Arduino for very long.

If my supplies are not enough, why did the following code work yesterday?

Perhaps the bluetooth module draws extra current.
Perhaps the analogWrite duty cycle was low enough for the battery to handle.
Perhaps you were lucky.


Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

I would have deleted it but i couldnt find any options to delete my topic

That is why you need to read those links !

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.