Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

Microprocessors

Final Project
Musical Doorbell Coded Bu8on
Inputs
By David Rubenstein
How to get songs to play
4 bu8ons
First bu8on push indicates which song will play
LEDs will light up indicaDng the next switches to
push (two at a Dme)
Cancel by pushing the opposite of the bu8ons
indicated
Push original bu8on again
If you push any other bu8on the board makes a noise
indicaDng the wrong bu8on was pushed
The Songs
PorDons of the following songs were wri8en
to the AT90S4414 microcontroller
Bu8on1 Three Li8le Birds Bob Marley
Bu8on2 Tessellate Tokyo Police Club
Bu8on3 Thunderstruck AC/DC
Bu8on4 Game of Thrones theme song
How song was programmed
Timer interrupt compliments speaker bit
Calculate reload values for notes
Create lookup table of reload values in
program memory
Note played for set duraDon. Brief period of
rest aWer each note played

tone = pgm_read_byte(&notes[16]); _delay_ms(200); //b4 1/8


tone = 0; _delay_ms(25);
Interrupt Service RouDne
ISR (TIMER0_OVF_vect)
{
TCNT0 = tone;
if (tone != 0) PORTC ^= SPKR;
else PORTC &= ~SPKR;
}
RepeDDon
Many songs have repeDDve note pa8erns. This is very easy to
implement with loops
Saves space in program memory
for ( int i = 0 ; i < 4 ; i++ )
{
tone = pgm_read_byte(&notes[12]); _delay_ms(400); //g4 1/4
tone = 0; _delay_ms(25);
tone = pgm_read_byte(&notes[5]); _delay_ms(400); //c4 1/4
tone = 0; _delay_ms(25);
tone = pgm_read_byte(&notes[8]); _delay_ms(200); //e4b 1/8
tone = 0; _delay_ms(25);
tone = pgm_read_byte(&notes[10]); _delay_ms(200); //f4 1/8
tone = 0; _delay_ms(25);
}
ImplementaDon of bu8on code
Result: Working Project

You might also like