User manual
mikroBasic PRO for PIC32
MikroElektronika
411
sub procedure ToneC()
Sound_Play(1046, 50)
end sub
sub procedure ToneE()
Sound_Play(1318, 50)
end sub
sub procedure Melody2() ‘ Plays Melody2
dim counter as byte
for counter = 9 to 1 step-1
ToneA()
ToneC()
ToneE()
next counter
end sub
main:
CHECON = 0x32
AD1PCFG = 0xFFFF ‘ Congure AN pins as digital I/O
TRISB = 0xF8 ‘ Congure RB7..RB3 as input
Sound_Init(PORTD, 3)
Sound_Play(880, 1000)
while TRUE ‘ endless loop
if (Button(PORTB,7,1,1)) then ‘ If PORTB.7 is pressed play Tone1
Tone1()
while (RB7_bit <> 0) ‘ Wait for button to be released
nop
wend
end if
if (Button(PORTB,6,1,1)) then ‘ If PORTB.6 is pressed play Tone1
Tone2()
while (RB6_bit <> 0) ‘ Wait for button to be released
nop
wend
end if
if (Button(PORTB,5,1,1)) then ‘ If PORTB.5 is pressed play Tone1
Tone3()
while (RB5_bit <> 0) ‘ Wait for button to be released
nop
wend
end if
if (Button(PORTB,4,1,1)) then ‘ If PORTB.4 is pressed play Tone1
Melody2()
while (RB4_bit <> 0) ‘ Wait for button to be released
nop
wend
end if
if (Button(PORTB,3,1,1)) then ‘ If PORTB.3 is pressed play Tone1
Melody()