Shop OBEX P1 Docs P2 Docs Learn Events
needed: most annoying piezo alarm tones — Parallax Forums

needed: most annoying piezo alarm tones

xanaduxanadu Posts: 3,347
edited 2012-03-08 11:37 in General Discussion
Anyone got any really annoying piezo melodies to share?

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-03-08 11:37
    This is what I use when I get an error with my datalogging equipment.

    I'm not sure if the sound is so annoying or if it's annoying because I associate with an error.
    PUB Init(piezoPin)
    '' AND TIMING FOR MANY FUNCTION, typically:
    '' BS2.Start
      pin := piezoPin
      s:= clkfreq                               ' Clock cycles for 1 s
      ms:= clkfreq / 1_000                      ' Clock cycles for 1 ms
      us:= clkfreq / 1_000_000                  ' Clock cycles for 1 us 
      Last_Freq := 0                            ' Holds last setting for FREQOUT_SET
      note[0] := 262                'c'
      note[1] := 294                'd'
      note[2] := 330                'e'
      note[3] := 349                'f'
      note[4] := 392                'g'
      note[5] := 440                'a'
      note[6] := 494                'b'
      note[7] := 523                'c"
      note[8] := 587                'd"
      note[9] := 659                'e"
      note[10] := 698                'f"
      note[11] := 784                'g"
      note[12] := 880                'a"
      note[13] := 988                'b"
      note[14] := 1047                'c"'
    
    [COLOR=#ff0000]PUB Bonk[/COLOR]
    [COLOR=#ff0000]  Freqout(250, note[4])
      Freqout(750, note[0])[/COLOR]
    PRI FREQOUT(Duration, Frequency) 
    {{
      Plays frequency defines on pin for duration in mS, does NOT support dual frequencies.
        BS2.Freqout(5,500,2500)    ' Produces 2500Hz on Pin 5 for 500 mSec
    }}
       Update(Frequency,0)                                 ' Set tone using FREQOUT_Set
       Pause(Duration)                                         ' duration pause
       Update(0,0)                                         ' stop tone
     
    PUB PAUSE(Duration) | clkCycles
    {{
       Causes a pause for the duration in mS
       Smallest value is 2 at clkfreq = 5Mhz, higher frequencies may use 1
       Largest value is around 50 seconds at 80Mhz.
         BS2.Pause(1000)   ' 1 second pause
    }}
       clkCycles := Duration * ms-2300 #> cntMin               ' duration * clk cycles for ms
                                                               ' - inst. time, min cntMin
       waitcnt( clkCycles + cnt )                              ' wait until clk gets there
    
     
    

    Do you have a S2 robot. It makes lots of great sounds.
Sign In or Register to comment.