Shop OBEX P1 Docs P2 Docs Learn Events
Boe-Bot police siren — Parallax Forums

Boe-Bot police siren

Joelectro66Joelectro66 Posts: 4
edited 2015-04-03 07:36 in BASIC Stamp
Hi everybody,

I would like to make the piezo speaker sound like a police.

Please answer my question.

Thanks

Joelectro66

Comments

  • GenetixGenetix Posts: 1,749
    edited 2015-03-20 16:45
    The 2nd program might be what you are looking for.
    http://www.dummies.com/how-to/content/electronics-projects-how-to-create-sound-effects.html

    The SoundPAL has American-Style Siren as one of the Canned Sound Sequences, accessed by the Play command.
    https://www.parallax.com/product/28825
  • Joelectro66Joelectro66 Posts: 4
    edited 2015-04-03 07:15
    Hi,

    Thanks for helping me, in first site, I tried the 2 codes but it didn't worked.
    The SoundPal is a good product, but I don't want to buy something.
    I just want to program the piezo speaker.

    Thanks again

    Joeletro66
  • PublisonPublison Posts: 12,366
    edited 2015-04-03 07:36
    BTW. Welcome to the forums!

    The first program in post# 2 should work:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    
    ' Siren Effect Program
    ' Doug Lowe
    ' July 15, 2011
    '
    ' This program generates a rising and falling pitch similar to a police siren.
    ' The rate at which the pitch rises and falls changes if you press either
    ' of the two pushbuttons.
    
    Speaker  PIN 0
    Switch1  PIN 10
    Switch2  PIN 14
    Frequency VAR Word
    Time   VAR Word
    DO
     FOR Frequency = 3000 TO 5000 STEP 15
      GOSUB SetTime
      FREQOUT 0, Time, Frequency
     NEXT
     FOR Frequency = 5000 TO 3000 STEP 15
      GOSUB SetTime
      FREQOUT 0, Time, Frequency
     NEXT
    LOOP
    SetTime:
     Time = 15
     IF Switch1 = 1 THEN
      Time = 5
     ENDIF
     IF Switch2 = 1 THEN
      Time = 2
     ENDIF
     RETURN
    

    You will need the two switches.

    Do you have a photo of your setup? That would help alot.
Sign In or Register to comment.