user17003: I was trying to play with Arduino this weekend and connected a DC motor to A0 and GND to measure the voltage it provides when I rotate it. 
However,
when I rotate the DC motor with my fingers to test out the readings I see that when rotated clockwise it generates voltage that can be read in Arduino. But when I rotate it counter-clockwise the values I get are 0 - this is probably because DC motor generates negative voltage (?).
How do I fix this so that no matter the direction of the turn I get always positive value?
I am trying to build a simple anemometer, just for fun for kids and plot the values, however can't do much when I get 0 on analogRead when wind blows from the other direction..

thanks for any input into this. 

user23841: You can use full wave rectifier, but there is a significant voltage drop on it.
Another way is using Voltage divider to provide 1/2 Vcc to one of the motor terminals. But then you can measure just 1/2 Vcc in both directions (without another Voltage divider)
Something like:


user3879: I wouldn't connect a motor (or indeed any inductive circuit) to a semiconductor without protection. This should limit -ve as well as excessive voltages.
The simplest is to use clamp diodes to Gnd and 5V and connect the motor via a resistor. This will limit any incursions to one diode drop either side of the supply voltage, which should be safe.

17003: <p>I was trying to play with Arduino this weekend and connected a DC motor to <code>A0</code> and <code>GND</code> to measure the voltage it provides when I rotate it. </p>

<p>However,
when I rotate the DC motor with my fingers to test out the readings I see that when rotated clockwise it generates voltage that can be read in Arduino. But when I rotate it counter-clockwise the values I get are 0 - this is probably because DC motor generates negative voltage (?).</p>

<p>How do I fix this so that no matter the direction of the turn I get always positive value?</p>

<p>I am trying to build a simple anemometer, just for fun for kids and plot the values, however can't do much when I get 0 on <code>analogRead</code> when wind blows from the other direction..</p>

<p><a href="https://i.stack.imgur.com/1wshU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1wshU.jpg" alt="enter image description here"></a></p>

<p>thanks for any input into this. </p>
 23841: <p>You can use full wave rectifier, but there is a significant voltage drop on it.</p>

<p>Another way is using Voltage divider to provide <code>1/2 Vcc</code> to one of the motor terminals. But then you can measure just <code>1/2 Vcc</code> in both directions (without another Voltage divider)</p>

<p>Something like:<br>
<a href="https://i.stack.imgur.com/5LXBG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5LXBG.png" alt="enter image description here"></a></p>
 3879: <p>I wouldn't connect a motor (or indeed any inductive circuit) to a semiconductor without protection. This should limit -ve as well as excessive voltages.</p>

<p>The simplest is to use clamp diodes to Gnd and 5V and connect the motor via a resistor. This will limit any incursions to one diode drop either side of the supply voltage, which should be safe.</p>
