undefinedI'm a big enthusiast of the ubiquitous computing concepts, specially when they go related to the disappearing computing ("designed to exploit rich combinations of invisible (or embedded within everyday objects) sensing/computational entities”). As Mark Weiser said, "the most profound technologies are those that disappear", and to achieve that, things get to get smaller. And that's what I like the most about the "ATtinies". The Attiny45/85 8-DIP has about 1 cm2 and consumes 300µAh on active mode (that means if we use a common 3V CR2032 that can typically provide 220mAh, it could sustain an ATtiny45/85 running actively for about a month). Nick Gammon did a marvelous job on describing some power saving techniques on Arduino - with plenty of interesting information over his entire forum - and managed to create, for instance, a device using a ATmega328 (which consumes slightly more energy than a ATtiny85) to flash one of the three available LEDs every 30 seconds in order to inform the current temperature (blue LED=too cold; red LED=too hot; third LED=normal) and had/has it running for over 500 days in a row without changing its batteries (3xAA). That's just amazing!

So, few questions about the "ATtinies":

Is there any difference programming for Arduino (Duemilanove, UNO, Nano, etc) and ATtiny?

Yes and no. I've found in many places  (here, here, here) that, due to memory limitation, ATtinies support most (but not all) Arduino functions. I understand that you can use all of them within your code, but not all of them work as expected due to hardware limitations (for instance, micros() or delayMicroseconds() don't accurately count microseconds). In my experience, for most simpler cases, you won't have problems. You won't be able to do very complex stuff with it anyway, since it has very limited resources (few I/Os and memory).

Can I program straight away for ATtinies on my Arduino IDE?

Despite the fact that their instruction set are the same (Atmel AVR instruction set), their hardware specs are very different (number of I/O pins, pinout layout, internal resources like timers, interruptions, memory size, etc). As can be seen in the Arduino Build Process, the IDE uses a core file for each microcontroller, which implements the abstraction of the Arduino functions on that specific hardware, apart from the bootloader fuse bits configuration (that defines the microcontroller's clock speed - even though there's no bootloaders on ATtinies). The Arduino IDE doesn't come with the ATtiny core files as standard, but you can find them here . Follow the instructions found at /tiny/avr/README inside the zip file to know how to perform the installation and necessary configurations for the Arduino IDE.

How can I transfer my program to the microcontroller?

undefinedThe Arduino IDE can program most Arduino boards without any need of a third part programmer because of two things: the USB-to-UART serial converter (a chip present on the boards capable of converting the logic voltage levels between USB Serial and UART) and the bootloader (feature implemented in the microcontroller). As far as I'm concerned, you cannot program a "blank" Atmel microprocessor through UART serial connection. You can do that once it has a bootloader software running in it: a program that can read data from UART serial connection and re-program part of the flash memory with it.

To program an ATtiny flash memory from scratch we must use ISP (In-System Programming) through the SPI (to know exactly how it's done, low-level stuff, check here). Also, Ladyada has a nice and enlightening article on programming AVR microcontrollers which I recommend reading. At the Arduino's oficial page, there's also an article that describes how to program an Arduino (like to change its bootloader software) with ISP.

To program our ATtinies we'll construct a programming board with a DIP socket - so we can easily attach microcontrollers on it, program them, remove and use them on other breadboards/circuits. To do that, we'll need a spare Arduino board so we can use as our USB-to-SPI programmer. The board that I mounted was done following the instructions presented at this blog: http://brasilrobotics.blogspot.com.br/2012/03/aula-programando-attiny4585-com-arduino.html I believe they have better pictures of the board and its components over there, but the circuit is the same to the one presented at the picture that follows:

 

undefined

 

Before connecting this circuit to your Arduino board, you must program it with a special sketch that turns it into a AVRISP (AVR In-System Programmer).

undefinedOnce you've done that, connect your recently-created ATtiny programming board to the correct pins of your Arduino and configure your Arduino IDE use the Arduino as ISP and specify the board that you're programming:

undefined

undefined