Datasheet

void main() {
DDRB = 0x00; // Configure PORTB as input
Sound_Init(); // Initialize sound pin
Sound_Play(500, 1000); // Play starting sound, 2kHz, 1 second
while (1) { // endless loop
if (PINB.B7) // If PORTB.7 is pressed play Tone1
Tone1(); //
while (PINB.B7) ; // Wait for button to be released
if (PINB.B6) // If PORTB.6 is pressed play Tone2
Tone2(); //
while (PINB.B6) ; // Wait for button to be released
if (PINB.B5) // If PORTB.5 is pressed play Tone3
Tone3(); //
while (PINB.B5) ; // Wait for button to be released
if (PINB.B4) // If PORTB.4 is pressed play Melody2
Melody2(); //
while (PINB.B4) ; // Wait for button to be released
if (PINB.B3) // If PORTB.3 is pressed play Melody
Melody(); //
while (PINB.B3) ; // Wait for button to be released
}
}
424
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroC PRO for AVR
CHAPTER 6