Using a generator / motor as a rotary input


I'm looking to create a rotary encoder input device to use on an Arduino.

What I want is for users to rotate a crank and for the Arduino to sense the direction and approximate speed of the turn. The accuracy is not important, but the durability / tactile response is more so.

Software wise I'm competent, but my electronics is a little rudimentary.

My initial thought was to use an optical rotary encoder. However these are so small that attaching a crank handle to them I fear would just rip it apart immediately, plus there would be no resistance to the rotation.

So my other thought, remembering my school physics, was could you use an electrical motor or a hand generator instead? (I guess basically they are more or less the same inside). These would be more robust and would provide some resistance.

Anyone have any experience or advice on how this could be achieved? I guess at for basics, you attach the output of the motor to the analogue input pin. Turning the handle creates a voltage. The harder bit is to match the output voltage to the input voltage? or to stop the motor blowing the circuit if turned quickly.
Also if you turn a motor the opposite way does that reverse the voltage. Would a motor output an AC or DC signal?

Or perhaps I'm barking completely up the wrong tree?


The motor/generator has no physical load unless there is an electrical load.

If it has no electrical load, the output voltage will be high.

To demonstrate this, get a motor and spin it, it has no physical load.

Put a short across the wires and try again, it will be harder to spin.

This I'd assuming a brushed DC type motor.


The no-load voltage produced by a brushed DC motor is proportional to the shaft rpm, and the sign changes in accord with the direction of rotation.

So, your scheme will work, but you must be careful not to feed negative voltages or voltages > 5 V to the analog input pin.

The attached circuit uses a voltage divider to provide 2.5 V to the analog input if the shaft is not rotating, and the output voltage will go up or down as the shaft is rotated, depending on direction. R3 should limit the current flowing into or out of the Arduino analog input pin to a safe value, if the voltage goes negative or > 5V.

You might add an additional, small capacitor (say 100 nF) from the analog input pin to ground, in case the motor output voltage is noisy.