(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);
		_delay_ms(200);
		PORTB &= ~(1 << LED_PORT);
		_delay_ms(400);
	}

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.
		_delay_ms(200);

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

		// Wait a little.
		_delay_ms(400);

		// 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: https://bitbucket.org/tinusaur/tutorials/src/1f61873ae382/tut001/src/main.c.

The circuit schematics, even though very simple, was drown on 123d.circuits.io and it is available at this address: http://123d.circuits.io/circuits/76781.

 

New PCB Designs Sent to Fab

Tinusaur Proto v0.1 m2

This is the Tinusaur Proto v0.1 m2 that I just finished and sent it to OSHPark for fabrication.

You can look at the latest schematics on http://123d.circuits.io at this address: http://123d.circuits.io/circuits/66662.

Below are the schematics and the PCB design, for reference.

Tinusaur Proto v0.1 m2
Tinusaur Proto v0.1 m2 – schematics
Tinusaur Proto v0.1 m2
Tinusaur Proto v0.1 m2 – PCB

The new prototype PCBs just arrived from OSHPark

Tinusaur PCB
Tinusaur prototype PCBs from OSHPark
Tinusaur prototype PCBs from OSHPark

The new prototype PCBs just arrived from OSHPark – great quality as usual.

I noticed that there are only few things that I may change before call it official: slightly move some components around so they fit better and become easier to solder; add one jumper for switch on/off the optional button cell battery on the bottom of the board; make some pads and holes larger; … and few other things.

The schematics available on 123d.circuits.io website at this address: http://123d.circuits.io/circuits/58269.

Tinusaur prototype schematics
Tinusaur prototype schematics

The board is shared on OSHPark website at this address: http://oshpark.com/shared_projects/bFNU3LQB.

Tinusaur prototype PCB
Tinusaur prototype PCB

Tinusaur Proto v0.1 m1 – Prototyping and Design Considerations

The Tinusaur

I have finally managed to finish the first version of the schematics and PCB‘s and to order the first 3 pieces. This work is based on some previous experiments and designs.

20131108_proto_01sc580x380fx

Schematics

The schematics is nothing special – it is the well known minimal configuration for the ATtiny plus just few addition components – some of them optional.

The required components are the 2 capacitors between Vcc/GND and the 10K resistor on the RESET wire.

There is RESET push-button connected to the micro-controller.

The micro-controller connects to the outside world through 2 headers – H1 an H2. They are in two different sizes for number of rasons: first – to have more connections available for wires, and second – to make sure we won’t mistake H1 and H2.

Next to the headers there is 1×2 connector for external power source.

There is an optional battery for application where built-in power source is needed.

20131108_proto_02sc324x440fx

PCB

The PCB is a fork of my previous work on a simple header board.

There are 4 holes in the corners in case the board should be fixed to another object.

On each side of the IC there are 2-row headers – on 2×4 and the other 2×5.

External power source connector is put along with the H2 header.

The ISP connector is at the top of the board. Between it and the rest of the board there is 1×6 header-like probe – this could be used for testing as well as for easier cutting off the ISP part of the board in case is not (or no longer) needed.

The pads for the optional battery are on the bottom.

The size of the board is approximately 24×36 mm.

The schematics available on 123d.circuits.io website at this address: http://123d.circuits.io/circuits/58269.