Introduction: HDDJ: Turning an Old Hard Disk Drive Into a Rotary Input Device

Picture of HDDJ: Turning an Old Hard Disk Drive Into a Rotary Input Device

A couple of years ago we built a fun system that would allow DJs to mix music tracks in interesting ways. Our design called for an input device that would allow the DJ to quickly seek through a track and find a specific playback position, and we wanted to be able to do this by spinning a rotary control with a flick of the wrist - much like turntable DJs can spin the record back and forth to do the same.

We found that we had only limited choices for building our device: we first tried to use rotary encoders, but it is not easy to find a cheap encoder that spins smoothly and freely. Another alternative was to buy some audio equipment (like turntables) that spin well and feel good to use - but this seemed both expensive and wasteful for our purposes. Then, while looking for inspiration amongst assorted junk in the lab, we came upon a broken hard disk drive with its case open. We admired the quality of the bearings in the motor that drives the disk plates, enjoyed the fact that even a soft flick would get it spinning for a long time, and wondered whether we could sample an output from it when it was spun by hand, in much the same way that an electric motor, when turned, acts as a dynamo and outputs a voltage.

The answer is yes - and it's a very simple process to turn a hard disk into a rotary input device that has some unique properties. All you'll need is an old hard disk drive, a few op amps, resistors and a programmable microcontroller of some kind.

In this Instructable we'll show the basic principles behind this hack, then provide the schematics and firmware for the HDDJ device (shown below) that we used in our project, and which includes a few extra buttons, lights and a motorized slider for good measure.

Step 1: Crack Open a Hard Disk Drive

Picture of Crack Open a Hard Disk Drive

Old, unwanted or broken hard disk drives (HDDs) are usually free and easy to get hold of. They come in all shapes and sizes, but the most common are the 3.5" HDDs that are used inside desktop PCs. We experimented with a number of different 3.5" HDD models, and found that most are suitable for our purposes (and would guess that smaller, laptop-sized disks would work just as well). The largest variation lies in how easy it is to open the case of some compared to others. Seagate HDDs, which often use plain Phillips screws in the casing, are our favorite.

The first step is to open the drive by removing all the screws that hold the case closed. Often these are torx screws, and you'll need an appropriate screw driver. Sometimes a screw will be hidden behind a label - so if you have trouble opening the case after all the screws seemed to have been removed, poke at the labels to find the culprit. If there is a label saying "Warranty Void if Removed," then, for sure, remove it.

Open the case, and reveal the disk platters in all their untouched glory. Never again will they be so free of fingerprints.

Remove the actuator that holds the read-write head, which stops the platters from spinning around freely. It's up to you how much more you want/need to remove (rule of thumb: anything sharp should go). The only thing that you need to keep attached are the frame, platters and spindle motor.

Thanks to Wikipedia for the "Anatomy of a Hard Disk Drive" image.

Step 2: Solder Wires to the Spindle Motor Contacts

Picture of Solder Wires to the Spindle Motor Contacts

Turn the HDD over, with the exposed platters facing down. Some older HDDs will have four wires coming out of the back of the spindle motor, in which case you can skip this step. Most, however, have an orangy-transparent flat-flex cable. In this case, what we are looking for are four exposed contacts at the back of the motor that we can solder some wires to.

Step 3: Probing the Motor Output

Picture of Probing the Motor Output

This is not really a necessary step, but more an illustration of what exactly we are trying to do.

If you have a access to an oscilloscope with multiple inputs, connect three of them to three of the wires soldered to the spindle motor contacts in the previous step (it doesn't matter which three). Connect the probes' ground clips to the fourth wire, then set the platter spinning.

The scope images below show the three waveforms that are generated when the HDD platter is spun by hand (the scale is set to 500mV per division in the vertical axis, and 20ms per division in the horizontal axis). Three perfect phase-shifted sinusoidal waveforms!

The three different pictures show what happens to the waveforms as the platter gradually slows down: they all decrease in both frequency and amplitude by the same amount.

These waveforms carry a lot of information, not only how fast the platter is spinning, but also in which direction it is spinning (clockwise, or anti-clockwise). More on this later.

The raw signals, as generated by spinning the motor by hand, are simply too subtle to be sampled directly by a microcontroller, so the next step is to amplify them into useful levels.

Step 4: Amplifying the Output

Picture of Amplifying the Output

Now you have signals coming from your HDD's spindle motor, it's time to amplify them, and in the process convert them to square waves that can be fed into a microcontroller.

The amplification can be done with a simple comparator circuit. Each comparator (the triangles in the schematic) has two inputs (+ and -) and one output. When the voltage on the (+) input is less than the voltage on the (-) input the output will be pulled down to the negative supply voltage, otherwise it will be pulled to the positive supply voltage or, depending on the model of comparator, float at high impedance (in which case a pull up resistor is required).

In the schematic below we have wired an LM324D opamp to function as a comparator (an explanation of how this works can be found here). The LM324D includes 4 comparator modules in a single package, which is perfect because in our case we need three (the 4th is not shown in the schematic).

One of the lines from the HDD is used as a reference, and is connected to the (-) inputs of all the comparators. The other three lines are connected to each of comparators (+) inputs. Not shown in the schematic, but also important, are the power supply pins of the comparators. The negative supply is connected to ground, while the positive supply is connected to Vcc (in our case +5V).

When the voltage of a signal pin from the HDD is greater than the reference the comparator output will be +5V, otherwise it will be ground. The outputs of this circuit (second image) can now be connected directly to the input pins of the microcontroller.

Step 5: Measuring Direction and Velocity of Spin

Picture of Measuring Direction and Velocity of Spin

In this step we take the outputs from the amplifier circuit in step 4 and input it to a microcontroller to convert them to something a bit more useful.

The images below show the output from the amplifier circuit as the HDD platter is spinning at various decaying velocities. As the velocity decreases the period of the wave increases. The first two images below show the platter turning in different directions. If we look at order in which the rising edges of the waves occur we see that in the first image (spinning clockwise) it's Yellow Blue Pink, whereas in the second (spinning anticlockwise) its Yellow Pink Blue.

The code for the microcontroller watches the inputs from amplifier for a rising edge. It also keeps track of which inputs the last two rising edges occurred on (we'll call the inputs Y, P and B). If we detect a rising edge on input Y, and the previous rising edge was on P and before that B, we know that the platter is spinning clockwise, same for P, B, Y and B, Y, P. Conversely if we detect a rising edge on Y, and the previous two rising edges were on B and P respectively, we know the direction is anticlockwise, and same for B, P, Y and P, Y, B. Any other combinations are regarded as noise and ignored.

In our implementation we use a PIC microcontroller. The inputs from the amplifier are connected to the interrupt pins of the microcontroller; these generate an interrupt on the rising edge of the input. Our code then looks at which input generated the interrupt and which inputs generated the last two interrupts. If a clockwise spin is detected a '>' character is output to the PC, if an anticlockwise spin is detected a '<' is output.

Because the frequency of the interrupts depends directly on the frequency of the waves, which is proportional to the speed of the platter the computer software can work out the velocity of the platter from the frequency at which it receives '<' or '>' characters.

Step 6: Schematics and Firmware for the HDDJ Device

Picture of Schematics and Firmware for the HDDJ Device

For our original DJing project we equipped the hard disk drive with eight additional buttons, six LEDs and a motorized fader to make the HDDJ device. We designed a custom circuit board and wrote some firmware that allowed us to connect all these controls (plus the input from the HDD platter) to a PC via USB. Here you can download the files needed to recreate this design in EAGLE format, plus the firmware that needs to run on the PIC microcontroller (youll need a suitable PIC programmer to do this).

How to test the HDDJ Device

1. Install the driver provided in the ZIP file

2. Plug in the HDDJ to a USB port of your computer (it will mount as a virtual serial connection, and assign it a COM port)

3. Use a terminal program (like Putty) to connect to the COM port, at 115200bps, 8 data bits, no parity bit, and one stop bit.

4. Try spinning the HDDJ platter: you should see a stream of '<' characters appear as it spins counter-clockwise, and '>' characters as it spins clockwise. The frequency of characters will depend on the velocity of spin.

5. Moving the fader will output the character 'f' followed by a number between 0 and 100. To control the position of the fader type the character m into the terminal window, followed by a number between 0 and 100, and then hit return.

6. Pressing the buttons will output the character 'b' followed by a number between 0 and 8. To turn the LEDs on and off type the character l into the terminal window, followed by a number between 0 and 6, and then hit return.

For our project we wrote a bit of software that communicated with the HDDJ via the USB serial line using this protocol. It would be a relatively small (but useful) step to adapt it to, for example, translate the control sequences MIDI messages, which would let you use the HDDJ with generic music or VJ'ing software out of the box.

Step 7: Video Summary

Here we have a video summary, showing the HDD connected to:

1. A comparator circuit, which amplifies to the output from the motors.

2. An oscilloscope, which shows the nice amplified square waves.

3. A microcontroller, which takes the square waves as input and uses them to determine the direction of spin. The microcontroller outputs (via serial line) the "<" character while the disk is spinning counter-clockwise, and the ">" character when it is spinning clockwise.

4. A computer, that takes the output of the serial line and shows it on the screen.

In the video we're pretty excited because we just got this working for the first time :)


ArugulaZ (author)2016-05-18

Quick, possibly silly question. Could you connect the pins of the hard drive encoder to the X-axis pins of a mechanical mouse? That way you wouldn't have to bother with a microcontroller or external drivers... it would just work right away. It would be great for playing games like Arkanoid, Tac-Scan, and Cameltry in MAME.

vnod2805 (author)2016-01-06

Can you let me know the code for Arduino for the same project, I want to try it using Arduino.....

FurtherThanTesla (author)2010-11-16

Hey, my HDD only had three wires (im guessing a motor in a "whye" config) but it gave me an idea. use the green wave as the reference for the other two (save urself an opamp) and it will output a grey code like a rotary encoder! this will also improve your resoloution since a 2-bit grey code has four states per revoloution, while your three-phase setup gives three per rev. it goes like this- Green wave is higher than other two= 00, green goes below red=10, yellow goes up above green allong with red= 11, red starts to fall below green while yellow stays = 01 - This pattern will repeat and give you four steps per rev while saving an exta op amp! ill try it out and let you know :D

fcotoro (author)FurtherThanTesla2015-11-20

Did it work? ^^

offnot (author)2014-12-07

Which program is need to make up HEX ?

MPLAB ? or any other programs ?

I got stuck in errors... Please help me any body...

my address is

enigmatik (author)2013-09-18

What is the purpose of 1k resistors in series with + signal?

BrunoARG (author)enigmatik2014-09-20

Those opamps are not working as linear amplifier but as schmitt trigger comparators. The ratio beween the 10K and 1K resistors and depending of the output high/low voltage determine the hysteresis.

That's used to turn the sine wave into a square wave that can be proccesed by the MCU. It could work without a schmitt trigger, but somewhen the output could take uncertain values.

MECHOL (author)2011-05-01


AJMansfield (author)MECHOL2013-08-11

I think you meant "inconceivable".

FurtherThanTesla (author)2010-11-16

Just tested it, and it outputs the Grey Code as expected and behaves just like I imagined. Tesla would be proud :D

yes tesla would be proud

erenjay (author)2012-02-08

sorry to ask such a basic question, but the zigzag lines on the schematic are capacitors, right?

project_builder (author)erenjay2012-02-14

no the zigzag lines are resistors

Rhamkota (author)2011-11-30

What if my hard drive only has 3 connections to the motor

vadipp (author)Rhamkota2012-02-05

Then you should find the "center" one using an Ohmmeter and _not_ use that one. See the right image in

vadipp (author)vadipp2012-02-05

Hmmm, I just realized that this project relies on all four wires. Sorry, I don't know how to fix it :)

charlyv (author)2012-02-04

Wow, what a way to steer a boat.
Like flipping the disk, each few revolutions being a degree of turn and then when you stop the disk, the processor nulls the rudder. Would make it so easy to navigate with a GPS in a narrow area. Some ideas on how to implement hydraulic or heavy servo mechanics using the control output of your design.... gonna look that kind of scenario up...

skeetshooter11 (author)2011-12-28

awsome idea

isantos (author)2011-12-05

Instead of a LM324D, Can I use a LM386?

project dude (author)2010-05-11

 Solder what kind of cables, standard electrical cables or audio or video cables?

Data643 (author)project dude2011-06-28

There isn't much of a difference between the two...

joearkay (author)project dude2011-02-23

22 gauge wire will do fine :)

SaNjA2659 (author)2009-04-11

WANT A PARTS LIST, And can somebody tell me, how can I put files into microcontroller, or can I ask to write files there in a radio shack?

blackbeardlion (author)SaNjA26592011-05-16

no you can't bring it to radio shack but you can make your own software using an avr microcontroller and the usb keyboard and mouse library. it's a bit of a task but you could learn allot if your new to microcontrolers

offnot (author)SaNjA26592011-02-06

You have to read some books about PIC.
If you are a beginner of PIC, I'll recommand you an easy book.

Add me up as a MSN friend, ""

natman3400 (author)SaNjA26592010-07-06

You need a microcontroller programmer.

MECHOL (author)2011-05-01


rlapse (author)2011-04-12

could this be done with the old spinny drums from VCR's, i think that that would look boss.

Lowkill (author)2011-03-03

Does the hard drive needs to be powered or I'm missing something here?

mman1506 (author)Lowkill2011-04-09

no. It does not, When you spin the platter it creates about 500 mv thats why you need a amplifier

CBMalloch (author)2011-02-27

I'm somewhat confused. The sine waves show three phases spaced at 120deg apart, and this implies that the fourth wire is some kind of common. This conflicts with the idea of "pick any three", because one is special.

Then, the outputs of the comparators show two signals in quadrature (90 deg apart) and one signal that is the inverse of one of the first two. Doesn't seem like the same device is being shown.

With four wires all alike, I'd expect them to be 90 deg apart, so there would be two pairs of inverse signals, with one pair leading the other by 90 deg. With three wires and a common (wye) I'd expect the three wires to be at 120 deg apart.

Do your pictures represent two different disk drives, wired differently?

Thanks for the instructable -- I'm going to try it myself.

efiscp (author)2010-12-25

I'm gonna implement this as a scrollwheel. A very fast scrollwheel. ;)

the_prototype (author)2010-12-06

hehe just realised I'm using exactly the same HDD as you are in the instructable :D
It's an IBM Desktstar, isn't it?^^
Really cool idea, my friends are gonna be like "wtf?" :D

tomtortoise (author)2010-11-17

can you make a schematic for JUST the rotary part no buttons or fader or lights and stuff because im thinking of using one of these for the most legit steering wheel ever for pc gaming

FurtherThanTesla (author)2010-11-16

one prob though. Once the platter stops rotating it gets a little upity. the lights blink with the slightest vibration of the whole thing, but once the platter is rotated again, its running smoothly. I Imagine this oversensitivity could be corrected with a high value resistor, or low value capacitor

FurtherThanTesla (author)2010-11-16

It should also give you some error detection. like, it is impossible for it to go from 11 to 00, or vise-versa, so you can tell it is misreading either by going too slow or too fast and ignore the reading

AriderM (author)2010-10-03

A couple months back I got this working. I used a Parallax basic stamp 2sx. Used an oscilliscope to find the correct pins. From there I connected them to the comparator (quad comparator in my case) and fed those to the stamp. It took me a few hours, maybe even a full day, but I got it working. I then took the serial out of the stamp and had that spit out to my desktop running virtualdj. Using midiYoke and some other stuff I changed the serial data to virtualdj midi commands. After that I could spin the disk and have the track play. The next step I have planned is to rebuild this setup and introduce a speed controller. This will allow me to set the speed of the disk by hand, press a button and have the speed controller maintain the disk spinning speed.

Ashiro (author)2010-08-22

Minor correction: "a very simple process". Change to: "a very simple process for an electronics engineering graduate with access to a lab for etching their own PCB."

jhakker (author)2010-07-14

I'd pay for one of these !

swathisanthu (author)2010-06-14

can u pleas send the HDDJ zip which is working pleazzzzzz

teinai (author)2010-06-14

Very very cool. I love the cubic fader tool in your paper too. It makes me very happy to be alive at this time when people are sharing brilliant ideas incorporating fun, music and technology. Makes me wish I was more focussed at university! Great work!!!

T-Hawke (author)2010-06-11

Very Cool. Adding this one to my to do list. I want to adapt or use in windows movie maker for a shuttle knob. Maybe size the platters and the case down to something more convenient that does not take as much space. Good instructable. Great idea.

mattgilbert (author)2009-08-30

Thanks for the instructable! I got one working with an Arduino:

I posted the Arduino code here:

Not quite how you did it, but I wouldn't have figured it out without this instructable. I used an old 1st gen iPod HD, and I only needed 2 pulse signals, amplified with LM386 op amps (would have used a LM358 dual opamp if I had one handy.)

It sends usb MIDI commands, routed by this program:

to a shoddy Max/MSP patch that I threw together.

SinAmos (author)mattgilbert2010-06-11

Sweet. What about with different inputs? Like actual tracks?

kbishop (author)mattgilbert2009-09-10

i got a question though, how do you connect the usb cable to the op-amps, or where does it play it's role on the schematics? i ask this because i'm really temped to try but never done usb stuff like this before

mattgilbert (author)kbishop2009-09-10

kbishop, if you mean my Arduino version, the Arduino communicates with the computer over USB, and it also powers and senses the output of the opamps.

SinAmos (author)2010-06-11

My kind of fun-zeyz.

project dude (author)2010-05-11

 too cool

dark_angel000 (author)2010-05-02

 this thing is awesome ..................................can i have the parts list too ................i sure am gonna try tp make this thing...................thankx

bmxlife (author)2009-05-07

can I please have a parts list 2

About This Instructable




More by nvillar:HDDJ: Turning an old hard disk drive into a rotary input device
Add instructable to: