Datasheet
Programming PIC Microcontrollers in BASIC - mikroElektronika
 Tone1
 Tone2
 Tone3
 Tone3
 Tone3
 Tone2
 Tone1
end sub
main:
 TRISB = $F0
 Sound_Init(PORTB, 2) ' Connect speaker on pins RB2 and 
GND
 Sound_Play(50, 100)
 while true
 if Button(PORTB,7,1,1) then ' RB7 plays Tone1
 Tone1
 end if
 while TestBit(PORTB,7) = 1 ' Wait for button to be released
 nop
 wend
 if Button(PORTB,6,1,1) then ' RB6 plays Tone2
 Tone2
 end if
 while TestBit(PORTB,6) = 1 ' Wait for button to be released
 nop
 wend
 if Button(PORTB,5,1,1) then ' RB5 plays Tone3
 Tone3
 end if
 while TestBit(PORTB,5) = 1 ' Wait for button to be released
 nop
 wend
 if Button(PORTB,4,1,1) then ' RB4 plays Melody
 Melody
 end if
 while TestBit(PORTB,4) = 1 ' Wait for button to be released
 nop
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/07.htm (15 sur 16)05/11/2004 02:27:46










