user60265: I have a problem with stepper motor direction. 
I want to change the direction of the stepper motor rotation, when the stepper motor shaft is stuck. 
For example, when I hold the shaft of the stepper motor with my hand, the direction should change.
How can I do it?
Someone told me you should calculate the current, but I don't know how to do this?
My material components:

Arduino 
stepper motor gearbox 12 V
ULN 2003A


user57281: When motors stuck their current draw increases, you can sense that increase in the current and then change the rotation of the motor. The simplest way to measure current is with using a shunt resistor, for sensing high currents, current sensors based on hall effect sensors is usually used. ACS712 is one example.
How to sense current using a shunt?
Basically we're measuring the voltage drop over a resistor (RS), but the voltage drop is too small for Arduino to measure so we need an opamp to "amplify" the input:

simulate this circuit – Schematic created using CircuitLab
The schematic above is the simplest way to measure the voltage drop at "LOW SIDE", there is differential mode and "HIGH SIDE" measurement methods.
The gain of opamp can be set with resistors and this formula:
VOUT = (1 + R2/R1) * V1
The output of opamp then can be calculated to get current using ohm's law:
I = V / R
A simple code to calculate current:
int rawAnalog;
float voltageDrop;
int resistor = 0.1;
float current;

void setup() {
  pinMode(A0, OUTPUT);
}

void loop() {
  rawAnalog = analogRead(A0); // Read A0 input
  voltageDrop = (rawAnalog * 5) / 1024; // Convert the raw value to voltage
  current = voltageDrop / resistor; // calculate the current
}

Bonus: INA219 is an easy to use high-side I2C module which can measure both current and voltage.

60265: <p>I have a problem with stepper motor direction. </p>

<p>I want to change the direction of the stepper motor rotation, when the stepper motor shaft is stuck. </p>

<p>For example, when I hold the shaft of the stepper motor with my hand, the direction should change.</p>

<p>How can I do it?
Someone told me you should calculate the current, but I don't know how to do this?</p>

<p>My material components:</p>

<ul>
<li>Arduino </li>
<li>stepper motor gearbox 12 V</li>
<li>ULN 2003A</li>
</ul>
 57281: <p>When motors stuck their current draw increases, you can sense that increase in the current and then change the rotation of the motor. The simplest way to measure current is with using a shunt resistor, for sensing high currents, current sensors based on hall effect sensors is usually used. <a href="https://www.sparkfun.com/datasheets/BreakoutBoards/0712.pdf" rel="nofollow noreferrer">ACS712</a> is one example.</p>

<p>How to sense current using a shunt?</p>

<p>Basically we're measuring the voltage drop over a resistor (RS), but the voltage drop is too small for Arduino to measure so we need an opamp to "amplify" the input:</p>



<p><img src="https://i.stack.imgur.com/BiIi4.png" alt="schematic"></p>



<p><sup><a href="/plugins/schematics?image=http%3a%2f%2fi.stack.imgur.com%2fBiIi4.png">simulate this circuit</a> &ndash; Schematic created using <a href="https://www.circuitlab.com/" rel="nofollow">CircuitLab</a></sup></p>

<p><sup>The schematic above is the simplest way to measure the voltage drop at "LOW SIDE", there is differential mode and "HIGH SIDE" measurement methods.</sup></p>

<p>The gain of opamp can be set with resistors and this formula:</p>

<p>VOUT = (1 + R2/R1) * V1</p>

<p>The output of opamp then can be calculated to get current using ohm's law:</p>

<p>I = V / R</p>

<p>A simple code to calculate current:</p>

<pre><code>int rawAnalog;
float voltageDrop;
int resistor = 0.1;
float current;

void setup() {
  pinMode(A0, OUTPUT);
}

void loop() {
  rawAnalog = analogRead(A0); // Read A0 input
  voltageDrop = (rawAnalog * 5) / 1024; // Convert the raw value to voltage
  current = voltageDrop / resistor; // calculate the current
}
</code></pre>

<p>Bonus: <a href="https://www.adafruit.com/product/904" rel="nofollow noreferrer">INA219</a> is an easy to use high-side I2C module which can measure both current and voltage.</p>
