SCIFI User Interface Designer Lukasz Wieczorek
Posted on December 21, 2012 by lukasz on arduino, Hardware

Attiny85 + arduino serial monitor


so I’m working on this cloud project with a co-worker and trying to get a capacitive switch to work with it. If you have ever worked with capacitive switches you know how tedious this can be. Now imagine you have no way to monitor output, well that is what I was running into. Problem is you can never know what the output is with stock settings of an attiny. So my solution comes from the good boys/gals of MIT.

Lets set up a little basic “hello world” type example.


Make sure you connect a 220k resistor between pin 3 and Tx(transmit) input of arduino and put a jumper from ground to reset. if you do not do this, you could damage your board and/or attiny. (refer to picture above or pseudo-schematic below).

burn baby, burn…the bootloader

I really had never done this before I had to tinker with an Attiny85, but what this does, according to arduino guide, is sets fuse bits and bytes on the chip that allows us to compile code on it. here is an except (skip if you don’t care about details, just know you need it):

The items in this menu allow you to burn a bootloader onto the microcontroller on an Arduino board. This is not required for normal use of an Arduino board but is useful if you purchase a new ATmega microcontroller (which normally come without a bootloader). Ensure that you’ve selected the correct board from the Boards menu before burning the bootloader…When you upload a sketch, you’re using the Arduino bootloader, a small program that has been loaded on to the microcontroller on your board. It allows you to upload code without using any additional hardware. The bootloader is active for a few seconds when the board resets; then it starts whichever sketch was most recently uploaded to the microcontroller. The bootloader will blink the on-board (pin 13) LED when it starts (i.e. when the board resets).

But what if I haven’t installed attiny for arduino?! I’m freaking out maaaan.

Lo, and behold! If you do not have attiny85 (or other attiny) installed for arduino, it’s you’re lucky day! If you do, just skip to next step. Here is how to install:

Support for third-party hardware can be added to the hardware directory of your sketchbook directory. Platforms installed there may include board definitions (which appear in the board menu), core libraries, bootloaders, and programmer definitions. To install, create the hardware directory, then unzip the third-party platform into its own sub-directory. (Don’t use “arduino” as the sub-directory name or you’ll override the built-in Arduino platform.) To uninstall, simply delete its directory. —arduino website

Download latest version (choose the with arduino-tiny in title):

For example, my directory looked like:
/Users/[username here]/Documents/Arduino/hardware

ISP Sketch

In order to program with arduino you have to upload a sketch so it knows what to do with itself. Else it gets all frantic paranoid 🙂 add this library to your arduino folder or download my modified version here: TinyISP

if you download source library you have to make some changes though (skip this if you download mine, I’ve already made these changes):

Navigate to the TinyISP_BuildOptions.h file

Locate this line…


…and change it to this (change the one to a zero)…


Locate this line…


…and change it to this (change the one to a zero)…


add the library

You also need to add the TinyDebugKnockBang library, download it here: TinyDebugKnockBang add it to your “Arduino > Libraries” folder

Next Step

choose your chip (ATtiny 84 (44/24), ATtiny 85 (45/25), ATtiny 2313 processor) in our case we have an attiny85. Remember we have to set at 8MHz because that is only speed the processor can use serial!

lets start simple, some test code:

#define KNOCK_BANG 1
#include <TinyDebugKnockBang.h>

#define Serial Debug
void setup() {
    Serial.begin( 9600 );

void loop() {
    Serial.println("Can it be true?! An attiny serial monitor indeed!"); // debug output

Once code is uploaded you have one more setting to go, set the serial monitor to 19200 on reading. I can’t confirm why it doesn’t match the read speed, but it might have to do with the clock speed being at 8mhz, but that is a total guess. If you know, leave a comment I am interested in knowing.

Screen Shot 2013-05-05 at 3.35.13 PM

Open up your serial monitor and type an exclamation mark “!” and this will initiate the serial monitor (I’ve noticed sometimes you have to open and close the monitor to get it to work right, and send it more than once. To turn serial monitor off, just send another “!”

other available commands are:

@  Toggle between holding the target in reset after programming and allowing the target to run immediately
#  Reset the target now or allow the target to run if it is held in reset
$  Hold the target in reset

special thanks to Coding Badly and Erni for all their help, most info comes from here: Arduino Forum

Join the discussion 9 Comments

  • Reply

    Francine Y. Mcmillan

    February 12, 2013 at 10:23 pm

    When you get a new blank microcontroller, you need to do a couple things before it will start running your sketches. You need to set the fuses on it, and possibly upload the Arduino bootloader to it, and you need to be able to actually upload the sketches to the chip. Fortunately, the Arduino folks have a great tutorial on how to use your existing Arduino to burn the bootloader onto a new chip and upload sketches to it. Unfortunately, this method isn’t really that permanent. I mean yes, you can keep a breadboard set up like that and just plug it in when you need it, but to me it seems messy. I wanted to make the process easier.

  • Reply


    April 17, 2013 at 4:43 pm

    I cannot seem to get your code to pass the compile check. I get the following error:

    ketch_apr17b.cpp.o: In function `TinyDebugSerial::begin(long)’:
    tiny/cores/tiny/TinyDebugSerial.h:682: undefined reference to `Debug’
    tiny/cores/tiny/TinyDebugSerial.h:682: undefined reference to `Debug’
    sketch_apr17b.cpp.o: In function `loop’:
    /Applications/sketch_apr17b.ino:13: undefined reference to `Debug’
    /Applications/sketch_apr17b.ino:13: undefined reference to `Debug’

    I’m pretty new to arduino and just bought my first attiny85. I successfully wired up my ’85 to a Duemilanove using these instructions ( and sent the blink sketch so I’m pretty confident that I’m programing it correctly.

    I copied the TinyKnockBang and TinyISP folders to ~/foo/Arduino/libraries, but I still simply cannot figure out how to get your code to work on my ’85 and send back data.

    I *really* want to figure out how to do a serial read from the attiny so I can use it to debug an intervalometer program that I’m writing that uses a POT. I just can’t figure out how to get a serial read to work.

    Thanks for the write up and any help you can offer.

  • Reply


    April 18, 2013 at 3:18 pm

    I figured out my problems; I’ve learned quite a bit from your entry and wrote my own and noting the steps that I found hard. I borrowed quite a bit from your blog including the awesome sketch you have.
    Thanks very much for your help!

    • Reply


      April 23, 2013 at 1:02 am

      @aaron. what parts did you find difficult?

  • Reply

    Ebony D. Kane

    April 26, 2013 at 5:31 am

    Many of the products SparkFun sells use an AVR, like an ATmega168 or an ATmega328, as a microprocessor. There are many reasons we like this microprocessor, not the least of which is that it is the processor used in Arduino. Just because a board uses an ATmega, though, doesn’t mean it’s an Arduino. However it does mean that code written for an Arduino can be used on a board that uses the same microprocessor! The only thing standing in the way of running custom code on a board with an AVR is actually loading the code onto the chip (since it likely isn’t loaded with the serial bootloader used on an Arduino). This tutorial is a guide on how to use an Arduino as a programmer to load code onto a standalone ATmega microcontroller.

  • Reply

    Orestis Mokas

    September 16, 2013 at 10:09 am

    Amazing tutorial. Fully detailed!

    I would also like to know what theme on your mac you are using if its possible, much appreciated 🙂

  • Reply


    April 10, 2014 at 1:41 am

    What the voltage of the capacitor, So I know I won’t blow my board or attiny85 out.

    • Reply


      April 3, 2016 at 3:49 pm

      Anything above 5V should be fine.

Leave a Reply