The software is written to enable the user to configure the clock at run-time using only two buttons: the '+'-button increases the current setting, the 'adv'-button saves the current setting and allows one to setup the next.

If the microcontroller is fresh from the programmer, the firmware doesn't yet know what the hardware looks like, so stuff like the type of fan and the angles the hands are on should be set up first. After that, the user can input the current time and after that's confirmed, the clock will start running.

The software mainly works by using three interrupts: the first one kicks in 500 times a second and is used for button debouncing and keeping time. The second one is dynamically adjusted to kick in 60 times per rotation of the fan and handles the showing of the hands by enabling and disabling the three colors of the RGB-led. The third one kicks in every time the fan generates an RPM-pulse. When that happens, the microcontroller will evaluate the speed at which the rotation-timer happens and adjust it when necessary.

The software for the clock is written in avr-gcc and released under the GPL v3, so if you want, you can modify it to display a clock on anything rotating quickly enough. If you come up with something interesting, please let me know!

Video of the led-fan-clock in action:

« Prev 3 


samand wrote at 19 Apr 2014, 16.52:

My fan is rotating clockwise and motion of clock hands on it is seen counterclockwise(The motion of clock hands is seen like a clock in mirror).How can I change the program to have correct motion & would you pls make this correction in final Hex, so that we have two Hex for clockwise & counterclockwise fan rotating ?BTW: What is the role of test.c in program?

samand wrote at 14 Apr 2014, 5.45:

Thank you for your reply! What`s max & min fan RPM for proper circuit performance?

Evil.Spock wrote at 13 Apr 2014, 1.26:

samand, The direction of rotation is irrelevant. It's the strobe rate of the LED that determines the perceived motion. Nice POV clock BTW. Personally, I would've used a 555 instead of a uC.

samand wrote at 12 Apr 2014, 15.27:

Good job,but for clockwise rotating fan what must we do?

Sprite_tm wrote at 3 Mar 2011, 16.51:

You can use any old 8MHz crystal. 10 or 12MHz makes the clock run faster; you'd have to change a few things in the code and recompile to make that work.

makakasirapuka wrote at 2 Mar 2011, 23.34:

Thank you for your reply! What crystal did you use in the project? What's the part number? Is there any other difference but for the frequency? What would happen if I use a 10MHz crystal or 12MHz? Should I change something in the code for the clock to work correctly?

Sprite_tm wrote at 2 Mar 2011, 23.00:

Yes, you could go without a crystal... but with the rc-osc having an 1% deviation, the clock could be running 14 minutes a day slow or fast. The warnings: Yes, I know they are there and what they warn about. It's basically the compiler being anal about syntax or processor-specific details, you can ignore them.

makakasirapuka wrote at 2 Mar 2011, 0.11:

holly shit! 我不想

makakasirapuka wrote at 2 Mar 2011, 0.08:

Probably, it's one of the most remarkable attiny2313 projects I've seen so far :-) Is there a way to get rid of that 8MHz crystal? Why can't we set up the fuses in such a manner to use the inbuilt crystal? Besides, I used crosspack on a mac to compile your code and got several warnings... : avr-gcc -c -mmcu=attiny2313 -I. -gstabs -I ../core/ -Os -Wall -Wstrict-prototypes -std=gnu99 main.c -o main.o In file included from main.c:4: io.h:14: warning: function declaration isn't a prototype main.c:11: warning: function declaration isn't a prototype main.c:22:2: warning: no newline at end of file avr-gcc -c -mmcu=attiny2313 -I. -gstabs -I ../core/ -Os -Wall -Wstrict-prototypes -std=gnu99 io.c -o io.o In file included from io.c:4: io.h:14: warning: function declaration isn't a prototype io.c:53: warning: function declaration isn't a prototype io.c:81:2: warning: no newline at end of file avr-gcc -c -mmcu=attiny2313 -I. -gstabs -I ../core/ -Os -Wall -Wstrict-prototypes -std=gnu99 rtc.c -o rtc.o avr-gcc -c -mmcu=attiny2313 -I. -gstabs -I ../core/ -Os -Wall -Wstrict-prototypes -std=gnu99 run.c -o run.o In file included from run.c:5: io.h:14: warning: function declaration isn't a prototype run.c: In function `__vector_4': run.c:20: warning: unused variable `mux' avr-gcc -c -mmcu=attiny2313 -I. -gstabs -I ../core/ -Os -Wall -Wstrict-prototypes -std=gnu99 setup.c -o setup.o In file included from setup.c:4: io.h:14: warning: function declaration isn't a prototype setup.c:20: warning: function declaration isn't a prototype setup.c: In function `init_offsets': setup.c:21: warning: passing arg 1 of `eeprom_read_byte' makes pointer from integer without a cast setup.c:22: warning: passing arg 1 of `eeprom_read_byte' makes pointer from integer without a cast setup.c:23: warning: passing arg 1 of `eeprom_read_byte' makes pointer from integer without a cast setup.c:24: warning: passing arg 1 of `eeprom_read_byte' makes pointer from integer without a cast setup.c: In function `btn_tick': setup.c:51: warning: passing arg 1 of `eeprom_write_byte' makes pointer from integer without a cast setup.c:66: warning: passing arg 1 of `eeprom_write_byte' makes pointer from integer without a cast setup.c:78: warning: passing arg 1 of `eeprom_write_byte' makes pointer from integer without a cast setup.c:93: warning: passing arg 1 of `eeprom_write_byte' makes pointer from integer without a cast avr-gcc -mmcu=attiny2313 -I. -gstabs -I ../core/ -Os -Wall -Wstrict-prototypes -std=gnu99 main.o io.o rtc.o run.o setup.o --output ledclock.elf -lm avr-objcopy -O ihex -R .eeprom ledclock.elf ledclock.hex avr-objcopy -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 -O ihex ledclock.elf ledclock.eep avr-objcopy: --change-section-lma .eeprom=0x00000000 never used

sam wrote at 15 Dec 2009, 7.36:

Awsome projects.... dont get tired of reading your articles. A+

biosman wrote at 30 Oct 2009, 6.52:

What a kick ass ! you should become a scientist, keep up !

Amos wrote at 30 Apr 2008, 2.36:

Hey, sprite: Why dontcha dig into that tip jar and get some proper schematic capture software? ;) j/k I love hand-drawn schemo's! BTW, this and all your other projects are great! Keep up the good work!

abunai hito wrote at 29 Apr 2008, 4.41:

Nice, I want one too, but since your using a tricolor led, wouldnt one piece of white paper suffice. Itd just reflect whatever colour the led is spitting out when its going. Save on some config time since all hands have same offset.

Werner wrote at 9 Mar 2008, 12.24:

Congratulations - i love this idea - very nice indeed!

Peter wrote at 23 Feb 2008, 13.52:

In order to drive more than 1 LED, I used 2N7000 FET instead of BC560. Could this be a problem as it is not fast enough? Thanks!

steve wrote at 23 Feb 2008, 8.42:

Hello。I am from China.and got this link from google.and I like this idea very much.and I try to built this project on a breadboard.and I got some problem.would you pls HELP me .and I seach the copyright message and not find you email address.would u pls sent email to me :shsteve @vip.163.com ,this way I can sent emai to u .thank very very much .

Sprite_tm wrote at 12 Jan 2008, 16.05:

Peter: Please mail me, the address is linked in the copyright message underneath the page. Debugging in the comments can be a bit hard :)

Peter wrote at 12 Jan 2008, 3.18:

Hi, I've seen a few ATMEL projects before on the net but none compels me to actually dive into it. But this one got me hooked. So, I start getting all the tools, programmer, attiny2313, software, components, etc, and follow the instructions and built this project on a breadboard. This is my first ATMEL chip project. I turned the thing on and the LED (I used a RGB LED) emit 3 colours (RGB), after few seconds, it blink and then it is off. A few seconds later, it start blinking in green every second. My fan doesn't show anything. I check and confirm pulses are coming in from the Fan but there are no pulses coming from attiny to drive the LED; only on and off. What am I doing wrong here? Please HELP!!

timer wrote at 5 Nov 2007, 15.31:

I thougt it was going to flicker a bit, nothing at all!

bm wrote at 1 Nov 2007, 15.50:

Yayo like fan clock. Make good bathroom fan!

Stretch wrote at 30 Oct 2007, 21.19:

That is very cool, as far as other ideas for platforms for the technology, a few guys have done it with old hard drives to ver cool effect. http://www.alan-parekh.com/hard_drive_clock.html http://instruct1.cit.cornell.edu/courses/ee476/FinalProjects/s2006/ja94/Amsel%20-%20Klitinek%20Final%20Project/ I really wanted to make one of these but was a bit confused by the electronics running the show. The biggest mod that I wanted to be made was the ability to have a cheap clock/watch that you intially set so that you can then have the rest of the clock set itself off that everytime it started. If you could sort that and explain it, you would be such a Legend. Cheers

Hunter wrote at 30 Oct 2007, 1.58:

i kinda understand how it works and that is really kewl... if you run for president, ill vote for you.

spockout wrote at 30 Oct 2007, 0.07:

Excellent project!! Regarding configuration and setting of the time, perhaps a spare serial port on the PC could be used (if the uC has a UART). The configuration and current time could be sent by a simple (python) script at bootup or whenever. Or even a GUI interface is possible.

joe57005 wrote at 29 Oct 2007, 3.28:

good job! to simplify the code, why not just use one strip with white near the inside, cyan in the middle and green on the outside for the differing lengths. (white being visible under red, green, and blue, cyan visible only under green and blue, and green visible under green light)

clubdoug wrote at 28 Oct 2007, 8.59:

Good work. Would be great to see an upsized version on the ceiling fan in my lounge room!

Shad´kian Ash wrote at 28 Oct 2007, 4.47:

Simple and cute, excelent job! Good and simple, twice good!

Sprite_tm wrote at 27 Oct 2007, 23.27:

Sorry for the madness with the '-s: major magic quote malfunction while moving to the new server. Should be fixed now and I'll modify the saved ones soon.

drew wrote at 27 Oct 2007, 22.06:

how about a pice of glass that flasshes ilumanated by the led over the fan insted kinda like an lcd screen? it would be the came princaple as a projector. in fact if you did that you could get a circular pice of plexiglas with one line on it and insted of the fan and ilumanate it from behind so it would project.

Miles wrote at 27 Oct 2007, 19.49:

Sweet, I think I want to put a small light on my car wheels at night, that way it will look like the wheels are stopped! :) Perhaps a 1-watt lumiled on my rear-view mirror would do the trick? Now to figure out how to tap into the speedometer, it might be cooler to make the wheel look like it is rotating backwards slowly. On the subject of 1 line/stripe, it is entirely possible with one line, just make a hood/shield for the led that signifies the shorter hand so that the light only reaches the center of the fan, tada: short hand. For a cool effect you can make the seconds hand the reverse, shielded in the center and illuminating the outside edge of the fan stripe. It might take a little fiddling, but this way you can get a stripe of super reflective material and it might even look better. Obviously you would need 3 LEDs, but they can all be the same color now, for shields, off hand I would use a length of tube from a pen for the short hand shield, this might be a bit tricky to aim, but it sounds cool.

n3ldan wrote at 27 Oct 2007, 17.05:

For those lesser minded folks: he\'s using one physical LED, but it\'s got separate RGB outputs. It\'s a 4 pin LED, no different than having three physical LEDs. You couldn\'t do the project as it is with just one line. @Simon E. That\'s my question as well, with just one strip it would look cleaner during the flashes too. Either way, it\'s a far more complicated project than I could handle. Keep up the awesome hacks :)

jarrod wrote at 27 Oct 2007, 16.34:

ahh WTF? major bug with the'''s

jarrod wrote at 27 Oct 2007, 16.32:

you can\'t just have more lines without having different colour led\'s. every time the led flashes it will illuminate all the lines... I think it would be better off just having one line and 3 led\'s, the \'efficiency\' would not be affected by having more led\'s. unless you are talking about cost. and besides who cares about a few led\'s? however having more lines would make the clock appear brighter simply because the led\'s can flash more often and so be more effective. however, it would be hard not to have the different coloured lines reflect colours they are not supposed to anyway, i think having only one line would be more neat. good job on the fan by the way :D

pengwin wrote at 27 Oct 2007, 13.38:

and how does having 3 led's and the extra work to control them, end up being more efficient than 1 led and a few extra lines on the fan? efficiency is about waste, it would be less efficient to have more led's compared to more lines on the fan.

blahblah wrote at 27 Oct 2007, 12.40:

use three leds: blue red and yellow, one for hour, minute, second, put all hands in alignment, but paint them the three colors- just different positions to indicate length

Dion bettjeman wrote at 27 Oct 2007, 7.59:

Ha! Wicked. Wheres that old fan i had laying around......

Alan wrote at 27 Oct 2007, 7.27:


jarrod wrote at 27 Oct 2007, 6.59:

or different colours...

James wrote at 27 Oct 2007, 6.22:

Because how do you tell the hour and minute hands apart? They have to be different lengths...

Simon E. wrote at 27 Oct 2007, 6.18:

Why make more than one strip? The same can be done with one white strip on the fan.

Leave a comment:

Your name:

What does this picture say?
Sorry, this is a captcha

Your comment:

© 2006-2014 Sprite_tm - Contact