Getting Started

(lily) #1

Chapter 8: C Pointers and Arrays


else // the end of song

point to the next tone in the Song-table

else // if not looping the song

0;
cbi(TCCR1B, 0); // stop Playing
TCCR1A = 0;
TCCR1B = 0;
sbi(PORTB, 5); // set OC1A high
}


_t)pgm_read_word(pSong + 0);
}

e the correct time-delays in the song

// Enable timer0 compare interrupt
TIMSK0 = (1<<OCIE0A);


re (CTC) mode, CLK/256 prescaler
00)|(4<<CS00);
}


}

{
Tone++; //


// get the byte that tells if the song should loop or not
loop = (uint8_t)pgm_read_word(pSong + Tone);


if( loop )
{
Tone = 1;
}


{
Tone =


}


Tempo = (uint8


else
Tempo--;


}


void Timer0_Init(void)
{
// Initialize Timer0.
// Used to giv


// Sets the compare value
OCR0A = 38;

// Set Clear on Timer Compa
TCCR0A = (1<<WGM01)|(0<<WGM
Free download pdf