Programming ATTiny85 Using Sparkfun Tiny AVR Programmer

Today I want to program an ATTiny85 for the first time. Just getting the blinky program to run is a good start.

The ATTiny85 is an 8 pin ATMEL microcontroller. 6 pins can be used for I/O and they are very cheap. I got mine for $2.84 at Sparkfun but you can get them for closer to $1 on eBay.


I purchased the Sparkfun Tiny AVR Programmer (model PGM-11801) to make my first attempts at programming a little simpler.

avr programmerInformation on the programmer can be found here:

My main source of information is the Hookup Guide found on the product’s info page:

Installing the Driver

The AVR Programmer requires its own driver which is found on the product page or here.

To get the driver installed I had to go into device manager to install the driver and tell it the appropriate location.

Setup Arduino IDE

You will need ATTiny hardware definitions for the IDE to work. You can get them from the product page or here.

Unzip the attiny directory inside the attiny-master directory. I moved this attiny directory to c:\program files\arduino\hardware which is contrary to the instructions (they put it in the c:\users directory).

You can now select the ATTiny85 (use the internal 1Mhz clock as per the instructions:

Now select the USBtinyISP programmer:

Ready to write some code. To keep this simple, I am copying the code straight out of Sparkfun’s hookup guide:

int blinkPin = 0;

void setup()
pinMode(blinkPin, OUTPUT);

void loop()
digitalWrite(blinkPin, HIGH);
digitalWrite(blinkPin, LOW);

Compiling and uploading in the IDE works just like it would for a normal arduino. I clicked the upload button, the code compiled and was uploaded. There is a tiny LED on the programmer that flashes as the code is uploaded. The sample code above flashes this LED as well so you know the program is working without having to put it on a bread board.

Well, that wasn’t too hard to get up and running. Now can I do it in Code::Blocks which is my preferred IDE?

Aug 2 Update: I did spend several hours researching getting code::blocks to work with ATTiny AND the arduino library. No luck and as I researched I came to the conclusion this wasn’t that important. I’m not going to be writing anything large for an ATTiny85. The arduino IDE linked to textpad will be adequate.

This entry was posted in c-tinys and tagged . Bookmark the permalink.

9 Responses to Programming ATTiny85 Using Sparkfun Tiny AVR Programmer

  1. Sean Straw says:

    The ATTiny AVR processors will open a whole new world of projects. The 84 and 85 sport 8K of flash, which can accomplish quite a lot, though even their lesser siblings like the 4x and 2x (with 4K and 2K respectively) can do quite a bit. The smaller package and fewer pins (useful when you don’t need a ton of I/O) are a big plus for homemade PCB projects, since you don’t need to run as many traces, and (if using through-hole), drill as many holes.

    If you have a Brother laminate label printer with USB interfaces that allow them to be plugged into a computer, you can create laminate labels to stick down to the top of the IC to identify the pins (well, not by all of their names, but PB0, GND, VCC, etc), which helps when breadboarding. Also handy for labeling DuPont headers and PCB connections after the fact, or cabling, etc. The printer doesn’t see constant use, but it’s quite handy when I do use it.

    To simplify reprogramming these in breadboards, I have several home-etched PCBs with SMD versions of different AVR processors mounted to them (one processor per carrier board), with header pins going down for plugging into the breadboard, and a 6-pin ICSP header on top with traces to the appropriate uC pins, so while the uC is plugged into the breadboard, I can connect the ICSP cable and re-flash it without disturbing the project wiring. After you’ve had to pull the uC a few times to plug it into a programmer, the convenience the header provides becomes very clear.

    Your Sparkfun device has a 2×3 pin header in the middle which matches an ICSP header layout. If you refer to , there’s a section titled “Output Programming Pins” which shows the pinout. – so, a section of 2-row Berg headers, some quick soldering, and a 6-pin ribbon cable, and you can use your programmer to drive ICSP.

  2. Sean Straw says:

    Quick correction – the 2×3 arrangement in the middle of the Sparkfun board is actually the ICSP for programming the ATTiny84 uC that runs the board itself – you would actually connect to the pins at the far end of the board (which sadly, aren’t in the common 2×3 arrangement) to drive ICSP out to a project board.

    The posting process also munched the URL I posted. Here it is again (hopefully):

  3. Pingback: Using the “ManRob” ATTiny Programmer / ATTiny Arduino Shield | Big Dan the Blogging Man

  4. dirk says:

    Nice writeup, Big Dan. I”m not using Arduino & thought maybe somebody else like me would stumble upon your blog (like), and perhaps be interested in an all-in-one script to test their tool chain. To that person I say: behold, an all-in-one *nix script to blink the LED on the programmer:


    # dirk mayhew feb 2016
    # tests AVR programming setup
    # assumes:
    # – user can sudo
    # – sparkfun’s AVR Programmer PGM-11801 in a USB slot (other USB programmers might work…)
    # – ATtiny85 chip in the programmer
    # – gcc’s avr suite installed
    # – avrdude installed
    # if successful, you will see the amazing blinking LED
    # but more important you will know all the parts of your programming system work
    # 3 file byproducts: main.{c, elf, hex}

    echo -e Build and test AVR ATtiny85 executable

    # —
    # create some code
    * dirk’s AVR setup test
    * kudos to
    int main (void)
    DDRB = 0b00000001;
    while (1)
    PORTB = 0b00000001;
    PORTB = 0b00000000;
    return 1;
    echo -e “$c_code” > main.c

    # —
    # compile the c code above into intel hex:
    avr-gcc -Wall -Os -DF_CPU=8000000 -mmcu=attiny85 -o main.elf main.c
    avr-objcopy -j .text -j .dat -O ihex main.elf main.hex

    # —
    # program the ATtiny85
    # for details on the options try
    # $man avrdude
    sudo avrdude -p t85 -c usbtiny -P usb -U flash:w:main.hex:i

    • Sean Straw says:

      Instead of assigning the code to a variable and THEN echoing that to a file and THEN running gcc on it:

      # note original source filename no longer at end of commandline, replaced with
      # -x c –
      # ‘-x c’ means presume ‘c’ language (because gcc has no filename to parse an extension from)
      # and ‘-‘ is stdin for the file data

      avr-gcc -Wall -Os -DF_CPU=8000000 -mmcu=attiny85 -o main.elf -x c – << CODEBLOB

      The '<< CODEBLOB' is a here-doc syntax – the 'CODEBLOB' bit is a more or less arbitrary string which MUST NOT appear within the text you actually want in your output. The bash shell pipes everything from the line after that up until it sees that same token again. This can be useful for a multifile cat operation where you want to place a header or footer on it within a script without having to have an intermediate file or echo operation. This also means there isn't a 'main.c' file left lingering about (but you do have the outputs of gcc and other operations).

      That said, makefiles are where it's at, and be sure to check all your projects into a git repository.

  5. martin tetreault says:


    I’m running into a problem, and I can’t find help anywhere. I.m trying to use the ATTiny85, but without the Arduino interface (too slow). I have no problem writing signal to pins (PORTB &= 0b00000001), But whatever I try, I’m not able to READ from the pin (PINB & 0b0000001).
    However, this is not entirely true. whatever I try (PINB & 0b000001, PINB & 0b000010, PINB & 0b000100, I’m always reading on the PIN 0 (physical pin 5).
    Does anywho have try to read the ATTiny pin without the Arduino function ?


    • Dan TheMan says:

      I’ve not tried to directly access the hardware like this so I am of no help, but go over to and I bet someone there will be.

      • martin tetreault says:

        great, thanks.
        I’m not sure the Arduino forum will appreciate my non-Arduino question, but anyway, I will try.

  6. Dan TheMan says:

    they (stackexchange) don’t have a group just for AVR and it seems like I’ve found AVR questions/answers there in the past. There is an electronics group as well but I would think the arduino group would be more appropriate.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s