sub-512 byte 8-color VGA demo with ATtiny4/5

Generate VGA out from ATtiny5 with 3 pins

Similar projects worth following
1kB sounded absurdly big, so I wanted to try something even smaller.

Enter ATtiny5 - small AVR that runs max @12MHz, has 512 bytes of flash (yes, half-a-kilobyte), 32 bytes of SRAM and reduced tiny core with just 16 CPU registers. CPU has 6 pins in SOT23-6 size.

As VGA requires pretty steady clock, I used LTC1799 as external oscillator to run chip at 12MHz. Disabling reset-pin of ATtiny5 I was left with 3 usable pins (as 3 others are reserved for VCC, GND and Clock). I'm pushing HSYNC, VSYNC and 3 colors out from 3 pins.

The trick is to use the fact that pins actually have 3 states: Pulled high, pulled low and floating. Using simple diode + pull-up-resistor together with the fact that HSYNC and VSYNC signals are "idle high" and VGA monitor R,G & B lines have internal 75ohm pull-down, I can drive HSYNC/RED and VSYNC/GREEN from same pin. Blue comes out from disabled reset pin, which acts as "weak output pin", but seems to be just enough!

Project uses ATtiny5 is 6-pin MCU, available in SOT23-6 case:

  • Reduced AVR tiny core (16 CPU registers)
  • 512 bytes of FLASH for firmware
  • 32 bytes of SRAM
  • 12MHz max. clock

Because VGA signal timings need to be pretty accurate, external oscillator was used. Any 12MHz oscillator should do, in this project I used LTC1799 resistor-configurable SOT23-5 footprint chip.

Red led is used as diode in pin-splitting circuit.

I will keep on improving this even after 1kB Challenge deadline, but in level_up -branch of the repository.


Source code

asm - 5.97 kB - 01/06/2017 at 06:40


Definitions for ATtiny5

inc - 12.71 kB - 01/06/2017 at 06:40



Compiled hex for those without AVR assembler

hex - 1.13 kB - 01/06/2017 at 06:40


  • 1 × ATtiny5 8-bit AVR MCU SOT23-6
  • 1 × LTC1799 Resistor configurable oscillator (SOT23-5)

  • I call this done for now

    Jari Tulilahti01/22/2017 at 04:13 3 comments

    492 bytes, so there's 20 bytes of flash free on chip. I kind of call this done, but got some wavy text cramped in there too.

  • Mastering the code

    Jari Tulilahti01/21/2017 at 21:35 0 comments

    Now that the 1kB Challenge is over (Congratulations to winners! Awesome projects!) I merged the code to master and will continue development in that branch.

    Other news: PCBs arrived :)

  • 336 bytes

    Jari Tulilahti01/15/2017 at 23:42 2 comments

    Assembly complete with no errors.
    Segment usage:
       Code      :       168 words (336 bytes)

    Bars now slide in and out more nicely, also shrinking code :)

  • Hardware files added

    Jari Tulilahti01/11/2017 at 19:42 0 comments

    Added schematic and board files to level_up -branch in git:

    Board renderings added as pics.

  • 352 bytes

    Jari Tulilahti01/10/2017 at 15:34 0 comments

    Still shrinking - 352 bytes now :)

    Enhanced code is in "level_up"-branch, while master is still kept same as the code included here.

  • Schematics added

    Jari Tulilahti01/08/2017 at 05:09 0 comments

    Added Schematics as pic.

  • Taking out bytes

    Jari Tulilahti01/07/2017 at 17:40 0 comments

    I started taking this a bit forward - saved some bytes:

    Assembly complete with no errors.
    Segment usage:
       Code      :       177 words (354 bytes)
    The functionality of code is exactly the same.I created new branch called level_up to git repository where the changes are, but I will still keep on updating documentation etc. to master branch.

    Maybe there's some space for more effects soon? ;)

  • Better quality video

    Jari Tulilahti01/06/2017 at 07:22 0 comments

  • Final entry

    Jari Tulilahti01/06/2017 at 06:28 0 comments

    This is how the final entry looks like. Documentation missing.

  • Less than 400 bytes

    Jari Tulilahti01/06/2017 at 06:26 0 comments

    I'm about done. Code in Bitbucket, link added to project.

    avra  -l pentaveega.lst pentaveega.asm
    AVRA: advanced AVR macro assembler Version 1.3.0 Build 1 (8 May 2010)
    Copyright (C) 1998-2010. Check out README file for more info
       AVRA is an open source assembler for Atmel AVR microcontroller family
       It can be used as a replacement of 'AVRASM32.EXE' the original assembler
       shipped with AVR Studio. We do not guarantee full compatibility for avra.
       AVRA comes with NO WARRANTY, to the extent permitted by law.
       You may redistribute copies of avra under the terms
       of the GNU General Public License.
       For more information about these matters, see the files named COPYING.
    Pass 1...
    Pass 2...
    Assembly complete with no errors.
    Segment usage:
       Code      :       197 words (394 bytes)
       Data      :         0 bytes
       EEPROM    :         0 bytes

View all 13 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates