Do you like my hacking? If so, please consider leaving something in the
Current contents:
EUR102 (about $132.6) and a bunch of cool hardware.
Follow Spritesmods on Twitter!
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:
Last 10 comments Show all
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?
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.
holly shit! 我不想
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
Awsome projects.... dont get tired of reading your articles. A+
What a kick ass ! you should become a scientist, keep up !
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!
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.
Congratulations - i love this idea - very nice indeed!
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.