0

Basically I don't want to use an h bridge, I just want to protect my arduino when changing the direction of the motor.

The code i use:

void setup() {
  pinMode(2, OUTPUT);    // sets the digital pin 2 as output
  pinMode(12, OUTPUT);    // sets the digital pin 12 as output
}

void loop() {
  //ROTATE TO RIGHT
  digitalWrite(12, HIGH); // sets the digital pin 12 on
  digitalWrite(2, LOW); // sets the digital pin 2 off
  delay(1000);            // waits for a second
  //ROTATE TO LEFT
  digitalWrite(2, HIGH);  // sets the digital pin 2 on
  digitalWrite(12, LOW);  // sets the digital pin 12 off
  delay(1000);            // waits for a second
}

Scheme used:

enter image description here

I am using "dc motor 130" (3V-6V), I want to protect it from anything that could damage my arduino, giving it such use, and protection if the motor gets stuck, using a 1N4007 diode or resistors...

2 Answers2

1

You're trying to drive a DC motor (part 'dc motor 130') directly from logic I/O pins.

That motor draws 70 mA when idling, when 800 mA stalled (jammed or starting up).

The I/O pins have weak output high/low currents (IOH/IOL) and the voltage dropped by their output stages increases with the current drawn. The absolute maximum available is 50 mA but that's not for normal operation. This is explained in this question: 'How much current can I draw from the Arduino's pins?'.

So you will need an H-bridge or equivalent for bi-directional operation.

TonyM
  • 21,742
  • 4
  • 39
  • 62
  • I already got it to work with the schematic I showed above, I moved it in two directions, but I don't want to damage the arduino with the flyback, or if the motor got stuck. What do you suggest without using an h bridge? – MasachusetsPIN May 04 '21 at 05:49
  • I appreciate your answer, I will block the ma of the motor using a 100ohm resistance, making a drop of 3v 20ma, 0.06watt, I would appreciate if you could help me protect my arduino, from the change of directions or if it gets stuck. – MasachusetsPIN May 04 '21 at 05:50
  • I've read that h-bridges use a diode to protect themselves from the flyback of the motor, it's just that I don't know how to put it in my circuit? – MasachusetsPIN May 04 '21 at 05:53
  • You can use beefy logic buffers. Get two 4 output or 6 output buffers. Wire all the inputs on one of them to D2. Do the same thing with the other buffer on D12. See if you can find ones that have indefinite output short-circuit duration. – user57037 May 04 '21 at 06:14
0

It seems foolish to run the motor from a microcontroller's GPIO but you can protect from inductive spikes as shown in Figure 1.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. Four Schottky diodes protect the GPIOs from inductive kickback.

Transistor
  • 168,990
  • 12
  • 186
  • 385