Hi..
I'm having some trouble learning how to control DC motors. It feels like I know how to do it, as some of my practice circuits work perfectly, but next day they dont. (so I'm doing something wrong)
Here is a circuit I just made, that doesn't seems to work.
What I know:
A normal DC motor need more than the 5V the Arduino UNO can give, so I need a external power supply for the motor, for example the batteries, which in my case is one 9V battery.
My arduino needs to control the 9V flow to power the motor, which is where the transistor comes in.
Transistors (in my case, a NPN bjt) have got three pins. From left, flat side towards you, mine has: COLLECTOR - BASE - EMITTER.
Collector collects voltage, and depending on the voltage given to the base, different amount of current is allowed to flow from collector to emitter. So by connecting my pin 3 on the arduino, I can use a small voltage from the Arduino to make a large voltage from the battery run my motor. The arduino is also protected by the 9V with a resistor.
The diode is there because of "back EMF" or "back voltage" that the DC motor can produce when turned off but still spinning. If any back voltage, the diode creates a short circuit, ending the back voltage.
That is what I think I know, so if anything is incorrect, please say so.
This is my code, simply switching the voltage of the output pin 3 from HIGH to LOW and vice versa each second.
Using a multimeter:
- Only about 0.13V and 9mA is flowing through the motor, which is not enough I guess.
- Pin 3 is switching between 3-5V to 0-0.5V which seems right.
I've tried changing resistor for pin 3, removing the diode, etc.
The thing is that everything about me and npn transistors works perfectly when using this exact method, but controlling a LED on/off.
So I guess there is something missing in my knowledge on DC motor controllers, so I hope someone one you might know what it is I'm missing.
If any information you need to help me is missing, please say so and I'll give it.
Thank you in advance!
~ Captain
I'm having some trouble learning how to control DC motors. It feels like I know how to do it, as some of my practice circuits work perfectly, but next day they dont. (so I'm doing something wrong)
Here is a circuit I just made, that doesn't seems to work.
What I know:
A normal DC motor need more than the 5V the Arduino UNO can give, so I need a external power supply for the motor, for example the batteries, which in my case is one 9V battery.
My arduino needs to control the 9V flow to power the motor, which is where the transistor comes in.
Transistors (in my case, a NPN bjt) have got three pins. From left, flat side towards you, mine has: COLLECTOR - BASE - EMITTER.
Collector collects voltage, and depending on the voltage given to the base, different amount of current is allowed to flow from collector to emitter. So by connecting my pin 3 on the arduino, I can use a small voltage from the Arduino to make a large voltage from the battery run my motor. The arduino is also protected by the 9V with a resistor.
The diode is there because of "back EMF" or "back voltage" that the DC motor can produce when turned off but still spinning. If any back voltage, the diode creates a short circuit, ending the back voltage.
That is what I think I know, so if anything is incorrect, please say so.
This is my code, simply switching the voltage of the output pin 3 from HIGH to LOW and vice versa each second.
Code:
void setup() {
pinMode(3, OUTPUT);
}
void loop() {
digitalWrite(3, LOW);
delay(500);
digitalWrite(3, HIGH);
delay(500);
}
- Only about 0.13V and 9mA is flowing through the motor, which is not enough I guess.
- Pin 3 is switching between 3-5V to 0-0.5V which seems right.
I've tried changing resistor for pin 3, removing the diode, etc.
The thing is that everything about me and npn transistors works perfectly when using this exact method, but controlling a LED on/off.
So I guess there is something missing in my knowledge on DC motor controllers, so I hope someone one you might know what it is I'm missing.
If any information you need to help me is missing, please say so and I'll give it.
Thank you in advance!
~ Captain