Hard Drive Clock Trouble

So I saw this:LED Hard Drive Clock Demo - YouTube a while back and thought it was really cool so I wanted to build one of my own (and a few others as gifts).

My current problem is that it doesn't seem that the arduino is capable of outputting .185 millisecond pulses on it's PWM pins, which for the clock on a 5400 rpm drive would be equivalent to one "division" (like one second) on the clock.

My math is 60/5400 = .011 seconds = time for one revolution
.011/60 = .000185 seconds (185 microseconds).

Is the arduino capable of handling these timings? or am I relatively SoL?

the snippet of my code, which would amount to the second hand, is as follows (nothing complicated, but I may be doing something wrong):
analogWrite(redPin, 255);
delay(.185);
analogWrite(redPin, 0);
delay(1000);

the idea is it's on for one division (1 second hands width) and then off for a full second, so when it turns on again, it should be at the next position. Thinking about that logic some more... would it be at the right position a second later?

My arduino seems to work at 1 millisecond intervals ok, but obviously I'd need a much slower drive for that to be acceptable... and I think you'd be nearing the edge of POV at that point.

If anyone was interested, I found that it is possible to scrape off the magnetic coating on the older, glass drives so you don't need to cut a slit (which to my knowledge you can't easily do on the glass drives).

If it is any help to you Arduino can also work with microseconds
http://arduino.cc/en/Reference/DelayMicroseconds

hey yea! I didn't know about that bit of code. That should help me out a lot. I guess now I just really need a hall effect sensor to move forward.

Does anyone have any easy to follow code (ie not assembly)? I'm working on my own, but I'm also having trouble incorporating a function to keep track of the speed of the disc. How do you do so many things at once - by that I mean light LEDs for certain periods of time at certain times and keep track of a counter of some sort for the speed?

http://gonium.net/md/2006/12/27/i-will-think-before-i-code/

This is a link from Arduino's website about handling timer interrupts. If you modify the code to do something else at a certain time, you can use your main function for whatever you want. Also, I don't know how you are measuring the speed, but if it is through an external line, take a look at the site below. Hope some of this helps.

http://www.arduino.cc/en/Reference/AttachInterrupt

Does anyone have any easy to follow code (ie not assembly)? I'm working on my own, but I'm also having trouble incorporating a function to keep track of the speed of the disc. How do you do so many things at once - by that I mean light LEDs for certain periods of time at certain times and keep track of a counter of some sort for the speed?

Hmm. Now, this is actually the core challenge of the task you're trying to perform. The timing involved can be pretty tricky! And that's why, when someone figures it out on their own, everyone is impressed. :slight_smile:

I'll give you two hints. First, consider using interrupts instead of delays to get your timing right. Second, forget the analogWrite stuff for now; just use digitalWrite or even better direct port access so you can write all your LEDs at the same time.