' Make it with Micromite
' Part 7: Adding sound to a projet
'
' Listing 2: A simple siren effect using the PWM command
 

SETPIN 22,DOUT  		' set 0V supply to piezo
DO              
  FOR f = 400 to 2000 STEP 50	' sweep through frequencies, start at 400Hz, then 450Hz... to 2kHz 
    PWM 2,f,50     		' set the PWM output to frequency in variable f	 
    PAUSE 10			' short delay (10ms)
  NEXT f			' carry on up to 2kHz, then move to next line once 2kHz finished
  FOR f = 2000 to 400 STEP -50	' now sweep down from 2kHz to 400Hz in 50Hz steps 
    PWM 2,f,50     		 
    PAUSE 10
  NEXT f			' when back down at 400Hz...
LOOP    		        ' ...loop continually to create siren effect