0

enter image description hereenter image description hereProblem: I want to have a 9v battery that powers a dc motor. I want to control it with a bluetooth remote that has 3 buttons. 1st button is turn the motor with 1.5v, 2nd button is motor off and the 3rd button is full power (9v). Here is the problem normally I will change volt with my arduino using code, but it has a max voltage of 3.6v so I can't control the battery with the arduino. Also I would like the 9v battery to power the arduino and bluetooth module if that is possible, so I have only one battery that powers everything.

What I tried: I found a lot of different things on the internet. Pwm, Tip120 transistor, L298N and it only confuses me more I have no idea where to start. Spend 8 hours looking for stuff and no step further.

Result: I hope everything will work with a 9v battery and the bluetooth remote can switch between 3 different speeds.enter image description here![enter image description here]

closed as too broad by MichaelT, Glorfindel, MatsK, VE7JRO Aug 18 at 18:59

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    Too broad and off-topic, but I suggest you read about pulse-width modulation (PWM) control of DC motors, as well as the power requirements of your DC motor. Often alkaline 9 V battery won't cut it, try lithium batteries instead. – MichaelT Aug 11 at 13:24
1

You have 3 problems here:

  1. Driver circuit the motor: Since you only want to control the motors speed (not changing it's direction, where you would need a H-bridge like the L298N), a very simply driver circuit is sufficient. It can consist of a bipolar transistor or a MOSFET. The Arduino's digital output pin would set the transistor/MOSFET to conductive or non-conductive, which turns the motor on or off. The motor is connected (through the transistor/MOSFET) with the full supply voltage. For the needed circuit, you can google terms like "transistor as switch" or "MOSFET as switch". That should give you plenty of tutorials.

  2. Controlling the motor speed: Normally the speed of a motor is not controlled through the voltage, since the speed behaves not linear with the voltage. Instead we use PWM (Pulse Width Modulation), where a squarewave voltage with a constant frequency is outputted at the Arduino's pin. To change the motor speed, you change the ratio between ON and OFF time of the pin (called "duty cycle"). So the motor basically get's turned on and off very fast. Since the motor is to slow, to follow the fast change, we are basically giving it small pushes very fast. If you only push half of the time (duty cycle 50%), the motor will run with about half the speed. In Arduino code you use analogWrite(pin_number, x) with x between 0 and 255 to output a PWM wave at the specified pin. Refer to the Arduino documentation for details.

  3. Powering the whole device: First: A 9V block battery is actually like the worst choice for most cases (especially for devices with motors). It has a big series resistance, what means, that it cannot provide much current without dropping the voltage radically. They are meant for low-current devices. Better use multiple AA/AAA batteries in series.

    You didn't state, what Arduino you actually use, but from the description, it has to be one of the 3.3V boards, like the Arduino Pro Mini 3.3V version. Most Arduino boards also have a small voltage regulator on them. The input for it is mostly marked with Vin. Please refer to the documentation of your Arduino board, to check, which voltages are suitable for that voltage regulator. If you don't have a voltage regulator on your Arduino or your battery voltage doesn't fit, you have to provide the power through your own external voltage regulator. You should use a switching regulator (far more efficient, than linear regulators), which can provide the needed power (depending on the Arduino and the bluetooth device maybe between 50mA and 300mA, difficult to say generally) plus a bit overhead.

    You should then provide the motor with the full battery voltage, especially not through the Arduino's voltage regulator. Motors can draw quite much current. If you draw more current through a regulator, than possible, it will overheat, emergency shutdown or even burn out. If the battery voltage is not suitable, you should use a voltage regulator, that can safely provide the needed current.


Note: Depending on the size of the motor and it's load, you might want to add a flyback diode, that would safely let inductive reverse currents flow to ground, so that the inductive voltage is not piling up in the transistor/MOSFET.

  • 1
    Thank you so much! Finally I understand it! I will try this and let you know if it works! :) – Bart Aug 11 at 16:55
  • Again Thank you, almost everything works! Only thing I don't know is how I can add the diode against the back voltage. I made picture of the diagram that I use and I am not sure if its correct. And I made a picture of the project I am working on.(I post them with the orginal message.) I am not sure if i wired it correctly because my esp gets data from the com3 when the motor is turned(I think it's because of the back voltage). Also this way the diode became extremly hot. – Bart Aug 19 at 17:22
  • The diode is in the wring place. Currently all the motor current is flowing through it, so it gets hot. The flyback diode should bridge source and drain of the mosfet in the reverse direction, so that in normal operation it is blocking, leaving the operational function to the MOSFET. When the motor gets stopped suddenly, a negative voltage will build up at the MOSFET. The diode will then connect this voltage to ground, so that the voltage dissipates there and cannot ruin the MOSFET – chrisl Aug 19 at 18:00
  • I don't know, what you mean by com3, but this seems due to the motors noise. Shielding from noise can be a complex thing, too complex for this answer. Google about it, to find some fitting measures. – chrisl Aug 19 at 18:03
  • I made a picture again of my setup and also a diagram of the mosfet and it's connections. Is this what you meant? When I tried this I still get a blinking yellow light on my esp8266. (back voltage that probably gets in the board) Also I need to disconnect and reconnect my esp8266 otherwise it won't process any code. Can you see something I am doing wrong? It's a 1n4001 diode and I use PWM, does that make a problem? Thank you in advance! – Bart Aug 19 at 19:01

Not the answer you're looking for? Browse other questions tagged or ask your own question.