Tut 11 : Sound in PIC


8 ohm speaker

Circuit setup
 

PBP Program
'program PIC to sound speaker
 
DEFINE OSC 20
   @ device hs_osc                         'jika guna crytal 20Mhz
 
i var byte
j var byte
 
sound1:
 FOR i = 1 TO 100
    SOUND PORTB.3, [120,2,124,2,123,2,121,2]            ' first sound
 NEXT i

 FOR j = 200 to 210 step 1
 SOUND PORTB.3,[100,10,60,15,120,10,73,10]          'second sound alarm
 PAUSE 400
 SOUND PORTB.3,[120,10]
 PAUSE 400
 SOUND PORTB.3,[120,10]
 PAUSE 400
 SOUND PORTB.3,[120,10]
 NEXT j
GOTO sound1

No comments:

Post a Comment