Motor doesn't rotate without computer connection



My 5v dc motor only rotate when the computer is connected to arduino.
I want my motor rotate only with 9v battery, without connenction to computer
What should I do?
I am using a 9v battery. The Images uploaded is my code and circuit.

Welcome to the forum

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Such a battery is not capable of supplying the required current to power the Arduino for long let alone a motor. Consider using an alternative source of power such as 6 AA cells in series

If you have a multimeter then measure the battery voltage when it is powering the project

This is kind of contest for my school. I am actually designing a ball shooter and the given rule is only to use 9v battery. Is there any kind of way to solve it?

What is the exact wording of the rules ?

Do the rules state that you must use a 9V battery of that type ? To my mind, 6 AA cells in series constitutes a 9V battery

the rule says 'the students should make ball shooter only with provided stuff(part)' and professor said this consist the 9v battery so I can't use other kind of battery.

Are you sure that is the type of battery that will be provided ? With luck a fresh battery will last for a few minutes

Yeah i amsure. I also changed my battery to new ones a few time but it still doesn't work

Looking at your picture, how is the Arduino powered when using the battery ?

I actually don know how but the light on arduino board in turned on when only the battery is connencted

Connect +9V from battery to UNO Vin to power the UNO.

could you expalin more specifically?

2023년 5월 24일 (수) 오후 6:37, 2112 via Arduino Forum <notifications@arduino.discoursemail.com>님이 작성:

Your UNO isn't getting power.
The UNO uses the 5V from the USB port for power when you are plugged into the computer. The UNO needs power from somewhere when not plugged into the USB port. You give it that power by connecting the + side of your 9V battery to the VIN pin.

You connected 5V from UNO to the motor controller but there isn't 5V on that pin until you connect the battery to VIN.

Then should I use two battery?

It would be better if you did use a second battery connected to VIN and GND to supply a clean supply voltage to the UNO.

For now, connect motor controller +12V to UNO VIN pin to see if it starts working.

Thanks. I will try it till tomorrow!

ChatGPT just entered the room. I'm out!
Thank you.
That poor advice would have murdered his UNO

1 Like

AI nonsense deleted.

What exact L298N module are you using?
Is there a jumper close to the 12V connector?
Did they provide a schematic?
Can you post a pic of the module?

You may of may not want to connect the +5V wire if you use a second battery to power the UNO.

Use a pingpong ball :slight_smile:

image


Give us a link to the motor driver.

Hi, @anandrew

Can you please post an image(s) of your project?

In particular the motor driver module, we need to see what it has on board, there are many versions of the 298 module.

Thanks... Tom.. :grinning: :+1: :coffee: :australia: