Mikroelektronika MIKROE-350 データシート

ページ / 526
ToneA
ToneC
ToneE
next counter
end sub
main:
DDRB = 0x00                  ' Configure PORTB as input
Delay_ms(2000)
Sound_Init()                 ' Initialize sound pin
Sound_Play(2000, 1000)       ' Play starting sound, 2kHz, 1 sec-
ond
while TRUE                   ' endless loop
if (PINB.7 <> 0) then
' If PORTB.7 is pressed play Tone1
Tone1()
while (PINB.7 <> 0)      ' Wait for button to be released
nop
wend
end if
if (PINB.6 <> 0) then
' If PORTB.6 is pressed play Tone2
Tone2()
while (PINB.6 <> 0)      ' Wait for button to be released
nop
wend
end if
if (PINB.5 <> 0) then
' If PORTB.5 is pressed play Tone3
Tone3()
while (PINB.5 <> 0)      ' Wait for button to be released
nop
wend
end if
if (PINB.4 <> 0) then
' If PORTB.4 is pressed play Melody2
Melody2()
while (PINB.4 <> 0)      ' Wait for button to be released
nop
wend
end if
if (PINB.3 <> 0) then
' If PORTB.3 is pressed play Melody
Melody()
while (PINB.3)           ' Wait for button to be released
nop
wend
end if
wend
end.
360
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroBasic PRO for AVR
CHAPTER 6