A business card for common chiffchaffs

Â

This board was one of the first that I produced with my UV exposure box. First of all I checked the design for errors by printing it on regular paper.

first test prints

After finding the best arrangement I printed the final design on transparent film.

final design on transparent film

The chemicals I used were new to me and I didn't have a scale to measure the correct amounts so I had many-many failures before I could etch a decent board.

failed etches

The small speaker was scavenged from an old Nokia 3310.

finished board

It was a real challenge to fit the song of the bird on the tiny 4K program memory of the tiny45. I used a free tool made by Roman Black for encoding the sound into a 1-bit stream. Then I had to clip all the silence parts of the song to save some more space. The uC is in sleep mode until the button is pressed. Then it plays the birdsong and returns to sleep mode. It can operate for years from a single CR2032 battery.

Schematics:

Schematics of chichaff card

AVR C Code:

/*
 * main.c
 *
 *  Created on: 2011.07.11.
 *      Author: Adam Antok
 *     Contact: adam@antok.me
 *     License: Beerware
 */

#include <avr/io.h>
#include <util/delay.h>
#include <avr/pgmspace.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include "sound.h"

volatile uint8_t cnt;
volatile uint8_t sample;
volatile uint16_t currentsample;

volatile uint16_t samplestart = &csilp[0];
volatile uint16_t samplebytes = CSILP_BYTES;

volatile uint16_t pausecnt = 0;
volatile uint8_t track = 0;
volatile uint8_t songcount = 0;
volatile uint8_t gotosleep = 1;

int main(){
	DDRB = 0x10;
	PINB = (1 << PB3);

	set_sleep_mode(SLEEP_MODE_PWR_DOWN);

	TCCR0A = (1 << WGM01);
	TCCR0B = (1 << CS00);
	TIMSK = (1 << OCIE0A);
	OCR0A = 181; // 44100 Hz

	GIMSK = (1 << PCIE);
	PCMSK = (1 << PCINT3);

	sei();

	while(1){
		if (gotosleep){
			sleep_enable();
			sleep_cpu();
			sleep_disable();
		}
	}
	return 1;
}

ISR (TIM0_COMPA_vect){
	if (pausecnt){
		pausecnt--;
	} else {
		if (currentsample < samplebytes){

			if (++cnt & 8) {
				sample = pgm_read_byte_near(samplestart+currentsample);
				currentsample++;
				cnt = 0;
			}

			if (sample & 0x80)
				PORTB |= 0x10;
			else
				PORTB &= ~0x10;

			sample <<= 1;

		} else {
			currentsample = 0;
			cnt = 0;
			switch(++track){
			case 1:
				samplestart = &csalp[0];
				samplebytes = CSALP_BYTES;
				pausecnt = 11050;
				break;
			case 2:
				samplestart = &csulp[0];
				samplebytes = CSULP_BYTES;
				pausecnt = 8840;
				break;
			case 3:
				samplestart = &csilp[0];
				samplebytes = CSILP_BYTES;
				pausecnt = 11050;
				track = 0;
				if (++songcount == 3){
					pausecnt = 0;
					songcount = 0;
					gotosleep = 1;
				}
				break;
			}
		}
	}
}

ISR(PCINT0_vect){
	if (gotosleep){
		currentsample = 0;
		cnt = 0;
		track = 0;
		gotosleep = 0;
	}
}

Description

The chiffchaff is a very cute song-bird that is quite common in Hungary. I started this project because I really like the song of this bird and I wanted to create something in the "business card" form factor.

Technology

Â