User Tools

Site Tools


attiny

ATtiny85, a minimalist microcontroller

Background

This introduction in based on the wiki-prep and documentation Camille Moussette made for a workshop in 2011. Here I've rewritten some of the text to be a more general intro to ATtinys, but the original wikipage is here.

Luna Mod Looper, High Low Tech group at MIT, 1-Bit symphony, ATtiny family of processors, Arduino with other cores, Wiring, etc.

ATtiny85

Introduction

So you have been playing around with Arduino, you want to build something really small that doesn't really need to use that many pins or pull much power? Then the answer is ATtiny85. The chip only has eight pins, of which five are available to use with programming. As the picture above hints you can use three pins for analogRead() (i.e. sensor readings) and you can use two of them for PWM action. However all of them can be configured to act as digital pins via pinMode().

The ATtiny can run on anything from 1.8V to 5.5V which means you can easily run it off something as small as a button cell battery. I have successfully had it run leds, read buttons, play beepy sounds, run a small phone vibrator and even played around trying to use it in a ring (electro jewelry FTW!).

These are reprogrammable so I suggest you put them in a socket to allow for changing the behaviour or just correct bugs.

How to program ATtiny

Software options:

  1. Arduino 1.0 + ATtiny core from MIT High Low Tech group (this is the way we will work for this session)
  2. Arduino 023 + Arduino-Tiny

Hardware options:

  1. Dedicated ISP (in-system programmer), Tiny AVR programmer We have five in the workshop.
  2. Arduino as a programmer (Arduino as ISP), setup and information

Using Arduino 1.0 and the Tiny AVR programmer are my preferred tools for this; easy and familiar:

  • Download and install Arduino 1.0
  • Locate your Arduino sketchbook folder (you can find its location in the preferences dialog in the Arduino software)
  • Create a new sub-folder called “hardware” in the sketchbook folder.
  • Copy the attiny folder from inside the .zip to the hardware folder.
  • Restart the Arduino development environment.
  • You should see ATtiny entries in the Tools > Board menu.
  • program the ATtiny 85 @ 8 MHz, if you have a brand new chip remember to burn bootloader one time first (Tools menu) to set the right oscillator speed (default is 1 MHz, your code will run very slowy!!!)


Code sample

Simple Blink with sensor

void setup() {                
  pinMode(0, OUTPUT); 
}
 
void loop() {
  int sensorVal = analogRead(2);
  int wait;
  if(sensorVal < 800){
    wait = 200;
  }else{
    wait = 50;
  }
  digitalWrite(0, HIGH);
  delay(wait);
  digitalWrite(0, LOW);
  delay(wait);
}

Results from 2011 workshop

Camille ran a workshop exploring making your own circuits with copper tape and playing with the ATtiny. The results played christmas tunes, blinked leds and read buttons. Here are some inspiration and results of that.

uC Hobby has very information series on Arduino and sound: part 1, part 2, part 3, DAC options

Luna Mod Looper, a simple handheld synth and looper box that generates intriguing sonic rhythms. youtube

RTTTL (RingTone Text Transfer Language) RingTone library and online player

ATtiny85 basic sound

Download the sketch attiny85_basic_sound

ATtiny85 basic ringtone

Download the sketch attiny85_rigntone_1_0

Photos and Videos

attiny.txt · Last modified: 2013/09/02 14:04 by camille