POV(Persistence of vision) kit using AVR

This is my first serious(the first one was a one LED blinker) AVR project 🙂
I searched the Internet for a cool looking and easy to build project with ATTiny2313 and I end up on this page,it was a really nice project to start with so I made a list and I went to the local electronics shop to buy them, all the components + board cost me about 4$.
The schematic for it is :


and the components :

  • IC1 => ATTiny2313 (or AT90S2313)
  • C1,C2 => 30 pF
  • QTAL1 => 4 MHz quartz
  • D1-D7 => LEDs
  • R1-R7 => 100 Ohms

The construction is very simple.Below are some pictures :

After soldering the socket
Soldering the resistors and quartz
Preparing to solder the LEDs
The first version of the circuit (it is working on a 9V battery, I used a 78L05 regulator for this)

After building the circuit you can take the original source code that you can find on this article.
I wrote a small Visual Basic piece of software that let’s you build up your own messages that you can wave left and right to see what this project is about :P, it uses the so called persistence of vision effect (the illusion of floating letters in the air).
The current software let you generate codes for SPACE, A-Z and 0-9.


so just download it, write your text and copy & paste it to replace the existing text.

You can download the software + the source code (in VB6) here.

Here is my modified code based on the original one:

Visual Basic [Show Plain Code]:
  1. ‘set crystal value : 4MHz = 4.000.000Hz
  2. $crystal = 4000000
  3. Dim A As Byte , B1 As Byte , C As Byte
  4. Config Portd = Output
  5. Config Portb = Output
  6. Start:
  7. Portb = 00
  9. For C = 1 To 255
  10. Restore Xxx
  11. For A = 1 To 147
  12. Read B1 : Portd = B1
  13. Waitms 10
  14. Next
  15. Waitms 10
  16. Next
  17. Goto Start
  18. End
  20. Xxx:
  21. Data &H7E , &H01 , &H01 , &H7E , &H01 , &H01 , &H7E         ‘W
  22. Data &H7F , &H08 , &H08 , &H08 , &H7F , &H00 , &H00         ‘H
  23. Data &H3F , &H48 , &H48 , &H48 , &H3F , &H00 , &H00         ‘A
  24. Data &H40 , &H40 , &H7F , &H40 , &H40 , &H00 , &H00         ‘T
  25. Data &H00 , &H00 , &H00 , &H00 , &H00 , &H00 , &H00         
  26. Data &H3F , &H48 , &H48 , &H48 , &H3F , &H00 , &H00         ‘A
  27. Data &H00 , &H00 , &H00 , &H00 , &H00 , &H00 , &H00         
  28. Data &H3E , &H41 , &H49 , &H49 , &H2E , &H00 , &H00         ‘G
  29. Data &H7F , &H48 , &H4C , &H4A , &H31 , &H00 , &H00         ‘R
  30. Data &H7F , &H49 , &H49 , &H41 , &H00 , &H00 , &H00         ‘E
  31. Data &H3F , &H48 , &H48 , &H48 , &H3F , &H00 , &H00         ‘A
  32. Data &H40 , &H40 , &H7F , &H40 , &H40 , &H00 , &H00         ‘T
  33. Data &H00 , &H00 , &H00 , &H00 , &H00 , &H00 , &H00         
  34. Data &H3E , &H41 , &H41 , &H41 , &H22 , &H00 , &H00         ‘C
  35. Data &H00 , &H00 , &H7F , &H00 , &H00 , &H00 , &H00         ‘I
  36. Data &H7F , &H48 , &H4C , &H4A , &H31 , &H00 , &H00         ‘R
  37. Data &H3E , &H41 , &H41 , &H41 , &H22 , &H00 , &H00         ‘C
  38. Data &H3E , &H01 , &H01 , &H01 , &H3E , &H00 , &H00         ‘U
  39. Data &H00 , &H00 , &H7F , &H00 , &H00 , &H00 , &H00         ‘I
  40. Data &H40 , &H40 , &H7F , &H40 , &H40 , &H00 , &H00         ‘T

Also here is a test program to see if the LEDs are working fine :

Visual Basic [Show Plain Code]:
  1. ‘Title : LED mover
  2. ‘Author : Trimbitas Sorin
  3. ‘Webpage : http://stuff.nekhbet.ro
  4. ‘Date : 24/September/2006
  6. ‘set crystal value : 4MHz = 4.000.000Hz
  7. $crystal = 4000000
  8. ‘declare variables
  9. Dim X As Byte , Y As Byte , Z As Byte
  10. ‘configure the PORTD and PORTB for output
  11. Config Portb = Output
  12. Config Portd = Output
  13. ‘set PORTB to 0 (GND)
  14. Portb = 0
  15. For X = 1 To 255
  16. For Y = 0 To 6
  17. ‘set all LEDs to OFF
  18. Portd = 0
  19. Waitms 20
  20. ‘set all LEDs from 0 to current position to ON
  21. For Z = 0 To Y
  22. Portd.z = 1
  23. Next Z
  24. Waitms 20
  25. Next Y
  26. Next X
  27. End

To load it on the chip you need 3 things : the hardware programmer, the compiler (you need to compile the code to HEX format) and a software programmer (to burn the HEX file to your chip).
—For the first issue : I have build an extremly simple AVR programmer.To access it click here.
—For the second issue : go to www.mcselec.com and download the trial for Bascom AVR (it is limited to 4kb of code so it is PERFECT 😛 for our purpose), install it, create a new file (it will have .BAS extension) and compile the code (press F7 in the program window).
—And now the last issue : if you build the hardware I presented above them please go to AVReal homepage and download that software (don’t forget to install also the Win32 driver).

Win32 driver download here

The AVReal command line parameters should be something like :
“avreal32.exe +TINY2313 -p1 -ap -o0 -e -w -v -c YOUR_FILENAME.HEX”
If you have any problems on this just drop me few lines on the comments section.

Here is another cool looking testing program along with a small video of it (sadly my camera can’t capture the POV effect so that’s why I didn’t put any pictures/videos with it).

Visual Basic [Show Plain Code]:
  1. ‘Title : LED mover
  2. ‘Author : Trimbitas Sorin
  3. ‘Webpage : http://stuff.nekhbet.ro
  4. ‘Date : 24/September/2006
  5. ‘set crystal value : 4MHz = 4.000.000Hz
  6. $crystal = 4000000
  7. ‘declare variables
  8. Dim X As Byte , Y As Byte , Z As Byte
  9. ‘configure the PORTD and PORTB for output
  10. Config Portb = Output
  11. Config Portd = Output
  12. ‘set PORTB to 0 (GND)
  13. Portb = 0
  14. For X = 1 To 255
  15. ‘left to right
  16. For Y = 0 To 6
  17. Portd = 0
  18. Portd.y = 1
  19. Waitms 40
  20. Next Y
  21. ‘right to left
  22. For Y = 5 To 1 Step -1
  23. Portd = 0
  24. Portd.y = 1
  25. Waitms 40
  26. Next Y
  27. ‘i wrote this to keep it running smoothly 😉
  28. Portd.0 = 1
  29. Next X
  30. End

References :

36 comments on “POV(Persistence of vision) kit using AVR

  1. Pingback: MAKE: Blog

  2. Pingback: Technology Insight » Blog Archive » POV (Persistence of vision) using AVR

  3. Why do you need to occupy both ports? In other words, why can’t you just ground the resistor end of each LED leg?

  4. You are right, using simple LEDs there is no need to use both ports. 😀
    If you do the schematic above you can use also Bicolor LEDs and change between their colors by software.

  5. nice very nice.
    u did very well in making the article.its quite understanding.and the code generator is pretty amazing.
    before building this ckt most of us built(pov guys)ladyada’s minipov (http://www.ladyada.net/make/minipov2/index.html).the main problem we are facing is with generating code.there is no particular tool for that.i’ll be thankful if u could make a tool for the minipov too.

  6. I took a look at their schematic and they use 8 LEDS instead of 7 so the problem is that I will need to rewrite the characters code (it is easy but will require a lot of time). I’ll try to make some time next week to build it 🙂

  7. hi
    it seems u just updated the article its nice.
    if u have any more avr projects pls do post.

  8. I’m a little busy now for the next 2 weeks(school, work …) but after this period i will surely do another AVR project as I really enjoy doing this.
    When you get your minipov tool let me know so I can write a small message test program so you can test it and then I’ll release the 8LEDs software(I don’t own a minipov kit).
    Take care

  9. Hi,
    What do you mean with “he did’t mentioned any design details”? You mean the design of the board? If yes then it is easy to modify it to fit in such a tube + you can add a small connector so the device can support on-board programming 😉
    Enjoy the Sunday

  10. imean what type od batteries he used,is it consist of in circuit programmer or not.and that tube look like made of aluminium so how he managed to place the LED’s etc.

  11. hi there, i’v been following your tutorial wich I think is fnatastic! (better the the one from ladyada cuz she uses an ATtiny)

    the only problem is that while burning to eeprom I get a error message: Verifiyng CODE memory: Failed, 181 errors, (sometimes more some less)

    well I’m very worried, I even started to think that the 2313 is failing… and that is scary, one of those here in Peru are about $15!!! I’m currently using an at90s2313 – 10pi

    please please help me!!

    thanks in advance! 😀 seeya!

    ps:any english wrting related problem is done intentionally, dont think it was my fault 😛 😛 :p

  12. Actually it would be kinda easy to convert it to Visual C++ but sadly I’m a little too busy to do this now and I don’t see the point of the conversion. If you need help with the code then please ask and I’ll try to find the VB sources and send you the array needed to convert the characters.

  13. I can’t find the sources for it. You can build it from 0 if you really need a clone, it is just a great switch (select case) structure…

  14. i get a problem with avreal, i get the cant resync error then it stops, ive tried searcching google but all the pages are in russian, any ideas? ive typed and retyped the code a thousand imes… but no luck…

  15. Hi Tyler,
    It is hard to debug remote a circuit and I hadn’t played with avreal in the past few months.
    You can translate those Russian pages using http://www.google.com/language_tools , look at the bottom of the page and you’ll see “Translate a web page:”, insert there your URL, choose “Russian to English BETA” and press “Translate” 🙂

  16. Hey,

    I’ve just bought the stuff to build this..
    I was wandering how you would make a heart? Like for instance “I (heart) New York”
    What is the code for a filled out heart? Maybe
    theres is some easy way to figgure out myself? Help please! Thank you!

  17. Just wondering if i could get the textgen program? I just built the circuit and would like to edit the code.The software is no longer available .thanks

  18. Hi McGiver30 .. ohh, just now I saw that the links were gone.

    I just fixed them + added the source code in Visual Basic 6. Maybe someone will use it 🙂



  19. This seems like the perfect tutorial for me right now ,I spent hours looking for something like this. I am really hoping someone could explain briefly how to hex the files to get them on my chip. I have winavr installed but I cannot really figure out how to hex a file.If its too hard to explain maybe you could point me towards a tutorial. Thank you for posting.

  20. Thanks a million Trimbitas , I downloaded BascomAVR but I am still not too familiar with all the procedures or steps involved in using these programs, could you recommend a good tutorial for BascomAVR?

  21. :), you can take a look over their official help page : http://avrhelp.mcselec.com/

    If you only want to create the hex file (which you’ll load to the chip using AVRReal) .. open Bascom AVR anc copy & paste the code above, save the file, press F7 (Compile) and wait few seconds. Then at the same location as the newly saved .bas file you’ll see the hex file too.

    Hope this helps


  22. I love this project I wish I could make it with UsbtinyIsp but I cant compile with Bascom. If anyone knows how please let me know ..

  23. poti sa imi dai un simplu .hex gata de programat pentru tiny2313 cu cuvantul “Hesit8″… mersi… il folosesc cu setarile initiale de 8mhz cu 14 cicluri si 65 ms de startup ;;) 😀 ple help 😀

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.