Presenting the ATTinyest of ATTinys. The ATTiny4.

512 bytes of flash, running the classic "random number generator" (increment the number, but do it so quickly no one could possibly control it.)

/*
 * ATTiny4Test.c
 *
 * Created: 1/16/2014 8:34:30 PM
 * Author: Joe
 */ 

#include <avr/io.h>

// pin 1 attiny4 pb0 -> pin 4 LTM-8647AP serial data
// pin 3 attiny4 pb1 -> pin 5 LTM-8647AP clock
// pin 4 attiny4 pb2 -> switch with pullup to 5V, depressed = 0V.
//
// Datasheet for LTM-8647AP is http://optoelectronics.liteon.com/upload/download/DS-30-98-355/P_100_M8647AG.pdf

uint8_t ConvertNumToDisplayBitmap(uint8_t dig)
{
	uint8_t  cb = 0;
	
	// segment A - bit 0
	
	if (dig==0 || dig==2 || dig==3 || dig==5 || dig==6 || dig==7 || dig==8 || dig==9)
		cb |= 1;
			
	// segment B - bit 1
			
	if (dig==0 || dig==1 || dig==2 || dig==3 || dig==4 || dig==7 || dig==8 || dig==9)
		cb |= 2;
			
	// segment C - bit 2
			
	if (dig==0 || dig==1 || dig==3 || dig==4 || dig==5 || dig==6 || dig==7 || dig==8 || dig==9)
		cb |= 4;
			
	// segment D - bit 3
			
	if (dig==0 || dig==2 || dig==3 || dig==5 || dig==6 || dig==8 || dig==9)
		cb |= 8;
			
	// segment E - bit 4
			
	if (dig==0 || dig==2 || dig==6 || dig==8)
		cb |= 16;
			
	// segment F - bit 5
			
	if (dig==0 || dig==4 || dig==5 || dig==6 || dig==8 || dig==9)
		cb |= 32;
			
	// segment G - bit 6 and 7.  Segment G is divided into two segments on this 14 segment display.
			
	if (dig==2 || dig==3 || dig==4 || dig==5 || dig==6 || dig==8 || dig==9)
		cb |= 192;
	
	return cb;
}	

int main(void)
{
	CCP = 0xD8; // unprotect prescaler
	CLKPSR &= 0b11110110;  // set prescaler to 32 (on a 12mhz clock = 375Khz, to keep time with slower serial LCD chip)
	
	DDRB |= 0b00000011; // ports B0, B1 output, to LCD chip
	DDRB &= 0b11111011; // port B2 input, to produce "random" number

	uint8_t  i = 0;	
	uint8_t  curnum = 0;	
	
    while(1)
    {
		PORTB &= 0b11111101;	// clock low
		PORTB |= 0b00000001;	// data high
		PORTB |= 0b00000010;	// clock high

		if ((PINB & 4) == 0)
			curnum ++;
		
		if (curnum > 99)
			curnum = 0;
	
		uint8_t  lsd = curnum%10; // least significant, rightmost digit, digit "2" on display.
		uint8_t  msd = curnum/10; // most significant, leftmost digit, digit "1" on display.
		uint8_t  cb = 0; // current digit 0-9.
		
		cb = ConvertNumToDisplayBitmap(lsd);  // get least significant, rightmost digit, digit "2" on display.
		
		for (i=0;i<8;i++)
		{
			PORTB &= 0b11111101;	// clock low
			
			if ((cb & (1<<i)) == 0)
				PORTB &= 0b11111110;	// data low
			else
				PORTB |= 0b00000001;	// data high
				
			PORTB |= 0b00000010;	// clock high
		}
		
		PORTB &= 0b11111110;	// data low
		
		// pad it with zeros for segments we don't use.
		
		for (i=0;i<6;i++)
		{
			PORTB &= 0b11111101;	// clock low					
			PORTB |= 0b00000010;	// clock high
		}

		cb = ConvertNumToDisplayBitmap(msd); // get most significant, leftmost digit, digit "1" on display.
		
		for (i=0;i<8;i++)
		{
			PORTB &= 0b11111101;	// clock low
			
			if ((cb & (1<<i)) == 0)
				PORTB &= 0b11111110;	// data low
			else
				PORTB |= 0b00000001;	// data high
			
			PORTB |= 0b00000010;	// clock high
		}
		
		PORTB &= 0b11111110;	// data low

		// pad it with zeros for segments we don't use plus the 4 bonus outputs.

		for (i=0;i<13;i++)
		{
			PORTB &= 0b11111101;	// clock low
			PORTB |= 0b00000010;	// clock high
		}
    }
}

Nice job. It look like you've had flames shooting out of the power connector :).

pYro_65:
Nice job. It look like you've had flames shooting out of the power connector :).

I did. It was a tantalum cap next to the socket, it fried the socket (thrown away) and scorched this plug as well. I kept the plug, it isn't severely damaged. I posted about it here:

http://forum.arduino.cc/index.php?topic=182599.0

Cool :smiley: I have a couple of ATTiny10s sitting in my pile of bits somewhere that I have been meaning to do something with but have never gotten around to it.

How do you program them?

With the latest version of avr-gcc you can compile for them. You also need a programmer that can do the Tiny In Serial Programming thing (I forget its exact name). Fortunately there is an Arduino sketch floating around on the internet which allows you to use an Arduino as an programmer for them.

fungus:
How do you program them?

The protocol for the tiniest of ATTinys is called TPI (tiny programming interface). It's another serial type interface.

I used Atmel Studio, a totally free download from Atmel, which allows you to program Tiny/Mega/XMega/UC3 and a lot of the ARM (ATSAM) range of Atmel's offerings. It takes some getting used to compared to Arduino - take a look at that code. I've sampled XMega, UC3 and several ARM offerings from Atmel and it worked on all of them for me. You need a different programmer for ARM, though, it's a Segger clone that Atmel offers. Segger also has a student non-commercial version for about $65 which is good for all ARMs and that is the one I got. Atmel has made the other chips about as easy to prototype with as a complex Mega (like the 2560), though not quite as easy.

The programmer I used was just the AVR ISP Mk II

This programmer is cheap and I prefer it over the free solutions because that causes you, or at least me, to wonder if any problem encountered in programming your board is the board or the programmer. You can rest assured Atmel got this right, it works well.

For the UC3 you can't use the AVR ISP Mk II, you need the ATJTAGICE3, which in turn doesn't support the TPI protocol for the ATTiny4. So I ended up with the ATJTAGICE3, ATAVRISP2, plus the Segger student programmer (http://www.digikey.com/product-search/en?lang=en&site=us&KeyWords=J-Link+EDU+) which is a plus because it works with almost all ARM microcontrollers.