Shop OBEX P1 Docs P2 Docs Learn Events
Using BS2 to emulate "ding-dong" sound of a door bell — Parallax Forums

Using BS2 to emulate "ding-dong" sound of a door bell

KatyBriKatyBri Posts: 171
edited 2008-09-12 00:55 in BASIC Stamp
Hello everyone,

Does anyone know how to emulate the "ding-dong" sound of a door bell using a BS2. I think I've seen some examples using the SEROUT command to generate tones.

Thanks

Comments

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-09-11 05:00
    Try this:

      FREQOUT Speaker, 500, 600, 601
      FREQOUT Speaker, 500, 500, 501
    
    
    


    Each FREQOUT blends two tones that are 1 Hz apart in frequency. They start out in phase, which means their amplitudes add. By 1/2 second (500 ms) later, they are 180° out of phase, which means their amplitudes cancel. What this yields is a tone with a fast attack and a 1/2-second decay, rather like a bell. It's not perfect, but it's about the best you'll get with the Stamp. Unfortunately, you can't extend the tone beyond 1/2 second, wihout it increasing in amplitude again. Doing so produces a "wow" effect instead of a continued decay.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • KatyBriKatyBri Posts: 171
    edited 2008-09-12 00:55
    That's close enough. Thanks, Phil!
Sign In or Register to comment.