New Bundle: Tinusaur Starter 2

Tinusaur Starter 2 Kit

As you may already know last week we announced the Tinusaur Shield LEDx2 – this is very simple add-on board that you put on top of the Tinusaur Board. It has just 4 components: 2 LEDs and 2 resistors for each LED – there is no much to solder.

Now we have bundled this with a Tinusaur Board and an USB-ASP Programmer and that is now the Tinusaur Starter 2 kit. Great, isn’t it!

Tinusaur Starter 2 Kit

Check the links below for more detailed content information about each of the products included in this bundle:

IMPORTANT: Note that this is a kit, you have to assemble it yourself.

This bundle has its own page at Bundles / Tinusaur Starter 2.

Please, check the Where to buy page to see if the Tinusaur Starter 2 at the The Tinusaur Online Store.

New Product: Tinusaur Shield LEDx2

Tinusaur Shield LEDx2

As we’ve mentioned earlier (What is happening with this project?) we were working on shield-like add-on board for the Tinusaur Board.

So here it is …

Tinusaur Shield LEDx2 Parts

It has only 2 LEDs and 2 resistors for each LED so no much to solder.

This shield aims at 2 things – making it easier to …

This shield has its own page at Products / Tinusaur Shield LEDx2.

Tutorial 003: Making Sounds with Buzzer

Electromagnetic BuzzerSo far we’ve used a LED as output to produce light of different colors and intensity (Tutorial 001 and Tutorial 002) but we haven’t generated any sound yet.

In fact that isn’t very difficult to do.

We will use a buzzer for output.

According to Wikipedia … the buzzer or beeper is an audio signalling device, which may be mechanical, electromechanical, or piezoelectric. Typical uses of buzzers and beepers include alarm devices, timers and confirmation of user input such as a mouse click or keystroke.

Tinusaur BuzzerWe will use electromechanical buzzer. When voltage is applied to it its membrane moves up (or down, depending on the particular device) and respectively when there is no voltage the membrane goes back to its normal position. Applying constantly changing voltage will generate audio waves perceived by us as a sound.

Let’s connect the buzzer to the PB2 of the ATtiny85 on the Tinusaur board.

The program should look very much like the one for blinking LED except that the delay between switching the port should be very short.

In the example below we have a delay 500 and since we’re using the _delay_us() function that means the delay is 500 uS (microseconds). That means the period of the signal will be 2 x 500 uS = 1000 uS (or 0.0001 sec.) and then the frequency is 1 / 0.0001 S = 10000. That means the sound will have frequency of 10 KHz.

Here is the source code:

#include <stdint.h>
#include <avr/io.h>
#include <util/delay.h>
#define BUZZER_PORT     PB2     // Buzzer I/O Port
#define BUZZER_DELAY    500     // Delay for each tick
int main(void)
    DDRB |= (1 << BUZZER_PORT); // Set port as output
    while (1) {
        PORTB |= (1 << BUZZER_PORT);
        PORTB &= ~(1 << BUZZER_PORT);
    return (0);

Full source code with more comments and the other necessary files such as Makefile is available at

Build the program:

$ make

Upload the code to the controller:

$ avrdude -c usbasp -p t85 -U flash:w:"main.hex":a

The buzzer should start making sound immediately.

Let’s do some more experiments.

Let’s make the delay between the buzzer ticks change over time and see what sound it will produce.

This time instead of _delay_us() we will use the _delay_loop_2() function. According to the _delay_loop_2(int) documentation it produces 4 empty CPU cycles per iteration – in other words with parameter 100 it will produce delay of 400 CPU cycles. That tells us that the maximum is 65536 x 4 = 262252 cycles. That, at 1MHz CPU clock, is approximately 262 mS (milliseconds) maximum delay, … or about 3.8 Hz minimum frequency – perfect for our experiments.

Below is the source code:

#include <stdint.h>
#include <avr/io.h>
#include <util/delay.h>
#define BUZZER_PORT     PB2     // Buzzer I/O Port
#define BUZZER_DELAY    200     // Delay for each tick
int main(void)
    DDRB |= (1 << BUZZER_PORT); // Set port as output
    int delay = 0;
    while (1) {
        if (delay < 1) delay = BUZZER_DELAY;
        PORTB |= (1 << BUZZER_PORT);
        PORTB &= ~(1 << BUZZER_PORT);
    return (0);

After building and uploading this should start making sound like of a car alarm.

With similar techniques a lot more complex sounds could be generated.

This post will eventually become Tutorial 003.


The Tinusaur Plays Conway’s Game of Life

MAX7219 LED 8x8 ATtiny Tinusaur Conway’s Game of Life

I was playing with the MAX7219LED8x8 library and writing some code for how to use a simple scheduler to automate the task of outputting the buffer to the LED 8×8 matrix. So I was thinking … may be writing a simple game will illustrate the use of those libraries very well. Because just few days earlier I was looking at some Arduino projects implementing the Conway’s Game of Life I decided to write it for ATtiny85 and MAX7219/LED 8×8.

The Game of Life is a classical computer game and a cellular automaton created by the British mathematician John Horton Conway in 1970. This is a zero-player game which means that once it starts no input from user is required to play the game’s turns – it goes by itself.

Its simple rules (outlined below) allow to be implemented on very simple microprocessor systems and Tinusaur (and ATtiny systems in general) could be perfect platform for that.


One Tinusaur Board connected to LED matrix 8×8 controlled by MAX7219.


The MAX7219Led8x8 library is used to output the pixels to the LED 8×8 matrix.

MAX7219 LED 8x8 Conway’s Game of LifeThe Rules

The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, alive or dead. Every cell interacts with its eight neighbours, which are the cells that are horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:

  1. Any live cell with fewer than two live neighbours dies, as if caused by under-population.
  2. Any live cell with two or three live neighbours lives on to the next generation.
  3. Any live cell with more than three live neighbours dies, as if by overcrowding.
  4. Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.

The initial pattern constitutes the seed of the system. The first generation is created by applying the above rules simultaneously to every cell in the seed—births and deaths occur simultaneously, and the discrete moment at which this happens is sometimes called atick (in other words, each generation is a pure function of the preceding one). The rules continue to be applied repeatedly to create further generations.

(ref: Wikipedia/Conway’s_Game_of_Life)

The Program

The board is defined as a short byte array:

typedef uint8_t life_board[8];

An initial board is specified by the bits in that array:

life_board life_oscillators_blinkers = {

Here are the most important functions that are implemented:

void life_board_init(life_board buffer);
void life_board_out(void);
uint8_t life_cell_count(uint8_t cx, uint8_t cy);
void life_board_turn(void);
void life_board2_copy(void);

The life_board_init function initializes the board with preset values and life_board_out outputs the content of the boards to the LED 8×8 matrix.

The life_cell_count function counts how many neighbors the specified cell has.

The life_board_turn performs one turn of the game based on the rules described above. It reads the data from the main buffer life_board_buffer array and stores the result in the life_board_buffer2 array. After that life_board2_copy copies the new data to the main buffer which then is outputted to the LED 8×8 matrix.

Here is the source code of the most important function – life_board_turn:

void life_board_turn(void) {
    for (uint8_t y = 0; y <= 7; y++) {
        for (uint8_t x = 0; x <= 7; x++) {
            uint8_t count = life_cell_count(x, y);
            if (LIFE_CELL_ISSET(x, y)) {
                if (count < 2)
                    LIFE_CELL_CLR(x, y);
                else if (count == 2 || count == 3)
                    LIFE_CELL_SET(x, y);
                else if (count > 3)
                    LIFE_CELL_CLR(x, y);
            } else {
                if (count == 3)
                    LIFE_CELL_SET(x, y);
                    LIFE_CELL_CLR(x, y);

This function implements the rules of the Game of Life.

That’s it.

In the program there is some more code that shows about 10 well know and interesting shapes such as blinker, toad, beacon, glider, etc.

The source code is part of the MAX7219LED8x8 library and it is available at



This article was permanently put at Conway’s Game of Life page.

MAX7219 driver for LED Matrix 8×8

MAX7219LED8x8 is a C library for working with the MAX7219 display driver to control 8×8 LED matrix. It is intended to be used with the Tinusaur board but should also work with any other board based on Atmel ATtiny85 or similar microcontroller.

MAX7219 with LED matrix 8x8


The MAX7219 is manufactured by Maxim Integrated is compact, serial input display driver that could interface microcontrollers to 64 individual LEDs such as 8×8 LED matrix. Only one external resistor is required to set the segment current for all LEDs.

MAX7219 Timing Diagram

To put that in simpler words – with the MAX7219 driver it is possible to control 8×8 LED matrix using just 2 wires serial interface – one for the sync clock and one for the data. There is another wire that could be used to enable/disable the communication with the chip. The maximum frequency for the serial interface is 10MHz.

The LED matrix 8×8 is connected almost diretcly to the MAX7219 driver – only few external components are required.

Working with MAX7219 is very simple – turning on and off individual LEDs is done by sending 2-bytes command to the driver containing the row and the byte which bits define which LED value to set.

There are also few other command that are needed during the initialization process.

The library supports short buffer – only 8 bytes in size – to keep the values before sending them to the driver.

MAX7219LED8x8 is written in plain C and does not require any additional libraries to function except those that come with the WinAVR SDK.

Using it is very simple …

    MAX7219_buffer_set(2, 3); // Set pixel
    MAX7219_buffer_clr(4, 5); // Clear pixel
    MAX7219_buffer_out(); // Output the buffer

Please continue to MAX7219LED8x8 page to see full source code the rest of the article.

External Resources

The source code of the MAX7219LED8x8 library is available at

MAX7219 specification and datasheet:


Tutorial 002: Fading LED x1

Another beginners tutorial is on the way – this time about a fading in and out LED.

This is simple tutorial that shows how to connect a LED to the ATtiny85 based Tinusaur board and write a program that makes the LED to fade in and out using PWM (pulse-width-modulation) technique.

PWM Diagram

Note: The code in this tutorial does not use the built-in PWM capabilities of the ATtiny microcontrollers, instead it uses direct bit manipulation since this un easier way to understand how it works. Another tutorial should cover the PWM functionality that is built into the microcontroller.

Tinusaur Board with LEDThe Tinusaur board is a standard ATtiny breakout board so this could be applied to almost any other board that has ATtiny microcontroller on it. The code was tested to work with ATtiny13, ATtiny25, ATtiny45 and ATtiny85 but will probably work on any other ATtiny microcontrollers as well.

Please go to Tutorial 002: Fading LED x1 to see the full document.

You can also check the Tinusaur Board – Assembling Guide and the WinAVR – Setup Guide.


Arduino IDE – Setup Guide

Arduino IDEWe have put together a short guide how to setup and use Arduino IDE for programming the Attiny85 microcontroller and the Tinusaur Board in particular.

Note: This guide was tested under Microsoft Windows 8.1 operating system.

Note: The example source code was tested on ATtiny85 microcontroller installed on a Tinusaur Board and programmed using USBasp ISP programmer.

Note: This is not a guide how to use the Arduino IDE but rather how to setup one for use with AТtiny microcontrollers and specifically the Tinusaur.

The guide goes through the:

  • Installation of the Arduino IDE.
  • Setup the IDE for ATtiny and Tinusaur, adding boards definitions.
  • Setup USBasp Programmer, just brief overview.
  • Test the Arduino IDE with the Tinusaur, writing blinking LED program.

The entire Arduino IDE Setup Guide is available under the Guides menu.


(UPDATED) Tutorial 001: Blinking LED

Tinusaur Tutorial 001 schematics

Our first tutorial Tutorial 001: Blinking LED (that’s the older one) was just updated and put under the Tutorials menu.

This is very simple tutorial that shows how to connect a LED to the Tinusaur board and write the “Hello World” of the microcontrollers – very simple program that makes a LED to blink.

Since the Tinusaur board is a very standard ATtiny breakout board this could be applied to almost any other board that has ATtiny microcontroller.

The code was tested to work with ATtiny13, ATtiny25, ATtiny45 and ATtiny85 but will probably work with other microcontrollers too.

Please go to the Tutorial 001: Blinking LED x1 page to see the full document.


Tutorial 001: Blinking LED

Tinusaur Tutorial 001: Blinking LED

UPDATE: New version of this tutorial is available at the Tutorial 001: Blinking LED x1 page.

Tinusaur Tutorial 001: Blinking LEDThis is very simple tutorial how to make a LED blinking.

Since the Tinusaur board is a very standard ATtiny breakout board this could be applied to almost any such other board.

The code was tested to work with ATtiny13, ATtiny25, ATtiny45 and ATtiny85 but will probably work other chips too.

We assume that the Tinusaur board is already assembled, successfully; connected through the ISP programmer to the computer; and development environment . It is not the subject of this tutorial how to assemble the board or how to setup development environment.

The LED should be connected on pin 2 of the ATtiny – this is PB3 – through a resistor, and to the GND.

The LED, marked as D1, is just a standard light emitting diode.

The resistor, marked as R1,  is 270 to 330 ohm.

The most important fragment of the code is this:

	while (1) {
		PORTB |= (1 << LED_PORT);
		PORTB &= ~(1 << LED_PORT);

What is does is this:

  1. Start an infinite loop.
  2. Set the LED wire signal to “1” – that will make it to light.
  3. Wait a little – 200 milliseconds.
  4. Clear the LED wire signal to “0” – that will turn it off.
  5. Wait a little -400 milliseconds.
  6. Do it again.

Here is the entire source code:

 * The Tinusaur Project
 * Tutorial 001: Blinking LED
 * file: main.c
 * created: 2014-01-04

#include <avr/io.h>
#include <util/delay.h>

// ====================================
//                ATtiny
//               25/45/85
//              +--------+
//            --+ o  Vcc +------------
//  LED - PB3 --+        +--
//            --+        +--
//  ------------+ GND    +--
//              +--------+
// ====================================

// Define the I/O port to be used for the LED.
// This a number between 0 and 7 that tells which bit to use.
#define LED_PORT PB3

int main(void) {

	// Set the LED port number as output.
	// The DDRB is the data direction for port B.
	// This ...
	//  - shifts the "1" on left to the desired position and ...
	//  - does bitwise "OR" with the value in the port register.
	DDRB |= (1 << LED_PORT);

	// Start infinite loop.
	// (this is how most programs work)
	while (1) {

		// Set the LED bit to "1" - LED will be "on".
		PORTB |= (1 << LED_PORT);

		// Wait a little.
		// The delay function simply does N-number of "empty" loops.

		// Set the LED bit to "0" - LED will be "off".
		PORTB &= ~(1 << LED_PORT);

		// Wait a little.

		// Do it again ...

	// Return the mandatory for the "main" function value.
	return (0);

Copy the code above to your “main.c” file.

The source code could be also found on Bitbucket at this address:

The circuit schematics, even though very simple, was drown on and it is available at this address: