this is a mutli-mode clock project based on attiny2313. it employs a 8x8 led matrix as display. with the limited resolution, this 12 hour clock shows time in 6 different modes.

the circuit employs row and column multiplexing to drive the leds, one row at a time, this gives a 12.5% duty cycle when "sets" of leds (8 of them in each of the 8 rows) are turn on briefly. current limiting resistors are eliminated to save breadboard estate and as we are not constantly driving individual leds, they are not going to be damaged.

the control (user interface) is also arranged so that we only use one tactile button for input. the firmware capture long button presses (press and hold) for menu rotation and normal button presses for menu selection.

this is a hobby project and the clock is only as accurate as your internal oscillator calibration. i had not use a crystal in this project as doing so will upset the "matrix on top of mcu" breadboard layout. a crystal can be used to increase accuracy on a alternate breadboard layout (or pcb). with software compensation, i can achieve may be within 2 minutes off a day. i would need to adjust the time every 3 or 4 days to keep it usable. this is more a cubicle talk piece than a swiss time piece.

Below is video on full construction

Step 1: Display Modes

hhmm mode (see attached image 1) , typical hours plus minutes scrolling digits with colon separator.

seconds mode, shows only seconds.

tix mode (see attached image 2), led matrix is divided into quadrant, the upper quadrants shows the hour in bcd (binary coded decimal) values. they are represented by the number of dots to indicate the digits. the lower quadrants show the minute in bcd. i.e. for 9:36 it shows no dot + 9 dots on the upper half and 3 dots + 6 dots on the lower half.

dice mode (see attached image 3), the led matrix is divided into two set of 'dices'. with the upper pair showing hour from 1 - 12, the lower pair of dice shows minutes in 5 minute increments. i.e. for 9:45 it shows dice value 9 (upper) + 9 (lower) (9 x 5 min).

binary mode (bcd, see attached image 4), the hour, minute and second digits are show as binary dot on different rows in the led matrix. the rows 0 and 1 (from top) represents the hour digits, rows 2 is blanked, row 3 and 4 represent the minute digits, row 5 is blanked, row 6 and 7 represents the second digits.

Step 2: Features and Parts


* minimal components, 3 parts
* battery operated from 3V to 5V
* use of watchdog timer to keep time, power-down sleep mode takes about 1uA power
* calibration allow setup of seconds to gain for each hour
* this is a 12H clock, not 24H and has no AM/PM indicator
* not very accurate, planning to add RTC chip

parts list

* attiny2313v (v is low power version that works with 3V)
* 8x8 LED matrix display (red works best on 3V power)
* tactile button

led matrix pinout

the 8x8 led matrix has dot size of 1.9mm and is of common cathode, if you have common anode type, you can change a few lines in the code for adoption. see the following diagram and see if you have the right pin-outs. it appears they are quite common and if you purchase via ebay most suppliers have the same pin-out even if the model number is different.

. . . . . C8 C7 R2 C1 R4 C6 C4 R1 . . . . top row of pins (C is column, R is row)
. . . . . R5 R7 C2 C3 R8 C5 R6 R3 . . . . bottom row of pins

the 8x8 led matrix has dot size of 1.9mm and is of common cathode, if you have common anode type, you can change a few lines in the code for adoption. see the following diagram and see if you have the right pin-outs. it appears they are quite common and if you purchase via ebay most suppliers have the same pin-out even if the model number is different.

Step 3: Breadboard Layout and Assembly

. Cut to length 2 swg#22 wires and insert into breadboard as layout diagram shows.
. You may use other wires, I used core wires extracted from common network cables.
. Insert MCU (attiny2313v) into breadboard as per layout diagram.
. Insert LED matrix.
. Insert tactile switch.
. Schematic diagram also attached for references.

Step 4: Building and Flashing the Project

the source runs at about 500 lines and is rather self explanatory. the project was built in a linux ubuntu lucid box with avr-gcc toolchain.

the project is to be run at 1Mhz internal oscillator, you can use the following fuse setting via avrdude

avrdude -c avrisp2 -p t2313 -P /dev/ttyUSB0 -V -U lfuse:w:0x64:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m

although the project uses only a handful of letters for menu selection, i had included 38 characters in the rom. i.e. digits 0-9, letters A-Z, a '.' and a space character.

the tic mode and dice mode pattern selection is not true random as we had code size restriction.

per row leds brightness are compensated in software by adjusting how long a row of leds stays on and off. i.e. for rows with all 8 column leds on, we stay longer to make them appears to be as bright as those rows that have only one or two leds on.

watchdog timer is used as this allows for sleep mode to prolong battery life. this means that the clock is not that accurate. during sleep the timer wakes the system up 8 times a second to see if a key is pressed and to advance the clock.

source code for the project can be downloaded here


and make file here


<p>Can I use this code for arduino uno ? Im porting your code but failed D: so can you help me :D </p>
<p>Hey . can i use attiny2313a instead of attiny2313v? will it work properly?</p>
Can you point out in the code where to change the setup for a common anode type? Or point out where in code it uses the pinout so I can customize? I'm not super fluent in C yet. Thanks!
HI! Do you have the RTC .hex ready?? <br> <br>thank you! <br>marC:)
there is no RTC for this project. adding RTC is just an idea that did not happened. <br>i am playing w/ msp430's now and have not touch avr's for almost 2 years. <br>u are on your own :) <br>this project is interesting though, might re-do it w/ msp430 / TI launchpad. <br>
I have programmed using these commands. Is it okay? <br> <br>avrdude -c usbasp -p t2313 -V -U lfuse:w:0x64:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m <br>avrdude -p t2313 -c usbasp -U flash:w:mclock.ee.hex <br> <br>thank you! <br>marC:)
i can see u are using usbasp programmer. the mclock.ee.hex is eeprom, not flash, see below how to write both flash and eeprom. u need to adjust to your programmer though. <br> <br>from my make file <br> avrdude -c usbtiny -B 12 \ <br> -p t2313 -P /dev/ttyUSB0 -e \ <br> -V -U flash:w:$(TARGET).elf -U eeprom:w:$(TARGET).ee.hex <br>
I'm quite interesting using xtal along this project, but what would be the connection for : <br>click to download mclock.ee.hex <br>what is the difference between mclock.hex and mclock.ee.hex ?? <br>how do i use makefile along this project? <br>thank you so much! <br>marC:)
i can't help u now. i had unlearned / forgot how to program avr's. i haven't touch one for 2 years. now i am playing w/ msp430 solely. u need to find out how to use a clock crystal and use that for a timer to count / advance your seconds. <br>the ee.hex is for eprom. .hex is for program.
Do : ATTINY2313-20PU would work? <br> <br>thank you so much! <br>marC:)
yes, it would. you should power it w/ 4.5v or 5v though. <br>the led may be a little bit too bright and u can adjust the code to give more &quot;dark&quot; cycles during multiplexing. <br>** warning... this is a toy, not a real clock. I can builders told me it typically swift off one hour per day. <br>good luck w/. your build.
Hi Simpleavr<br>thanks for comment.I have load the .hexfile and i think it was start in Binarymode<br>Unfortunately,the tiny was burned in a few moments I had thought that leds are low current type&acute;s but it was not so what !<br>Is not so bad but i only have other &micro;c&acute;s like mega48 ,mega 8,16 and 32&acute;s<br>Is there a way to run the code on e.g mega48?<br><br>Otherwise coole Sache especially the binary mode<br><br>best regards
<br>Hi a!<br>I got the error <br>make.exe: *** No rule to make target `program'. Stop.<br><br>there created:<br>mclock.o<br>mclock.map<br><br>how i can make a .hex file?<br><br>a other case is where the resistors? are there inbuild the Module?<br>i have made a 8x8Matrix with 3mm Led&acute;s.<br>So i think i need 300-400 Ohms resistors
@hatschel my bad, i had corrected the makefile, please download again and make clean, make, will generate .hex now. had added and use avr-objcopy to generate .hex from .elf, like so<br><br> $(OBJCOPY) -j .text -j .data -O ihex $(TARGET).elf $(TARGET).hex<br><br>where $OBJCOPY is avr-objcopy and $TARGET is mclock.<br><br>if u want the hex files (.hex and .eeprom.hex) they are in my site<br><br>http://www.simpleavr.com/avr/multimode-clock<br><br>i didn't use resistors in this project to save space and parts, i just use multiplexing timing to avoid excessive current into individual leds, it's not ideal but it works.<br>
i also get make.exe mclock.elf Error1<br>don&acute;t know what this means<br>can you plz upload a file that i can flash?<br>I have the stk500 and the avr910 programmers
Hello.Canou make a instructable about the usb programmer plz.
the programmer used to program this project has been published as another instructable, u can search &quot;vusbtiny programmer&quot; to locate it.<br>
i will do it in two weeks time, about to finish the write-ups. but i don't know if u will be disappointed or not. you will need another programmer to program the tiny45 used in this programmer project. so if u don't have a programmer already, u can't make the project.<br>kind of a catch22.<br>
This project can not be used as a clock...It's Always stay back !
you are correct, originally it has a adjustment function where u can setup &quot;gains&quot; via the menu. after i add the dice and binary mode there is no room for that., a reader had built it and found it loss 1 hr per 24 hr. i had since update the code (in my web page) and u can adjust the accuracy at compile time.<br>still it is not accurate, i can manage to keep it within 5 min/day max.<br>i will find time to add the clock crystal option, u can also try. will post an update when it's available.<br>thanks for your comment.

About This Instructable




More by simpleavr:Tix Clock Gems Vintage TI DataMath / Sinclair Scientific Calculator Emulator AVR HVSP Fuse Resetter 
Add instructable to: