Shop OBEX P1 Docs P2 Docs Learn Events
Piezo Speaker? — Parallax Forums

Piezo Speaker?

Dan TaylorDan Taylor Posts: 207
edited 2009-04-25 17:43 in Propeller 1
I cannot figure out how to make a sound with the propeller chip and a pieze speaker! Can someone show me a simple code for a speaker connected to pin 3?
Thanks in advance!

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Dan Taylor

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2009-04-23 21:25
    Have a look at the Propeller Education Labs page 135. You can download it from the propeller download page.
  • Dan TaylorDan Taylor Posts: 207
    edited 2009-04-23 21:39
    I have been using the Propeller Education Lab, but I can't figure out how to use it. I am using the Propeller Demo Rev G, and it does not have a pin 27. So I have to change the pin.

    I also tried the program that has two speakers. One on pin 3 and one on pin 27. But it still doesn't work.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dan Taylor
  • VbrielVbriel Posts: 30
    edited 2009-04-24 04:36
    Maybe you are getting P3 mixed up with pin 3 on the chip. Just a thought.

    Vince

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Briel Computers

    http://www.brielcomputers.com
  • Dan TaylorDan Taylor Posts: 207
    edited 2009-04-24 18:57
    I just went over that. I don't think its that.

    I think I got confused with the code when changing the pin. Could you help?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dan Taylor
  • KPRKPR Posts: 189
    edited 2009-04-24 20:07
    Vbriel said...
    Maybe you are getting P3 mixed up with pin 3 on the chip. Just a thought.


    Vince

    Hey Vince.. nice to see your here too.. A2 Forever!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New ICON coming, gotta wait for the INK to heal, now we have colour!
  • Timothy D. SwieterTimothy D. Swieter Posts: 1,613
    edited 2009-04-25 02:37
    Can you post the code you are trying to use? Post it with your changes to P3.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Timothy D. Swieter, E.I.
    www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, 3.0" LCD Composite video display, eProto for SunSPOT
    www.tdswieter.com
  • VbrielVbriel Posts: 30
    edited 2009-04-25 05:19
    Hey A2forever, small world.



    Hey Dan, yeah, if you can just paste the code, any info would help. It's always the little things, AWLAYS.



    Vince

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Briel Computers

    http://www.brielcomputers.com
  • Dan TaylorDan Taylor Posts: 207
    edited 2009-04-25 13:19
    Here is some of the coding that I have tried from book Propeller Education Kit Labs:

    ''SquareWaveTest.spin
    ''Send 2093 Hz square wave to P27 for 1 s with counter module.

    CON
    _clkmode = xtal1 + pll16x ' Set up clkfreq = 80 MHz.
    _xinfreq = 5_000_000

    PUB TestFrequency
    'Configure ctra module

    ctra[noparse][[/noparse]30..26] := %00100 ' Set ctra for "NCO single-ended"
    ctra[noparse][[/noparse]5..0] := 27 ' Set APIN to P27
    frqa := 112_367 ' Set frqa for 2093 Hz (C7 note) using:
    ' FRQA/B = frequency
  • Thomas FletcherThomas Fletcher Posts: 91
    edited 2009-04-25 13:31
    I just used the led blink program from the Propeller manual.


    PUB Toggle
      dira[noparse][[/noparse]16]~~
      repeat
        !outa[noparse][[/noparse]16]
        waitcnt(800_000 + cnt)
    



    The lower the waitcnt number the higher the pitch.
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2009-04-25 15:40
    Try this. the output will be on physical pin X that p3 maps to on your board. I tested it on a Hybrid board and it outputs to physical pin 4

    [code]
    CON
    _clkmode = xtal1 + pll16x ' Set up clkfreq = 80 MHz.
    _xinfreq = 5_000_000

    PUB TestFrequency

    'Configure ctra module
    ctra[noparse][[/noparse]30..26] := %00100 ' Set ctra for "NCO single-ended"
    ctra[noparse][[/noparse]5..0] := 3 ' Set APIN to P3

    frqa := 112_367 ' Set frqa for 2093 Hz (C7 note) using: ' FRQA/B = frequency
  • Dan TaylorDan Taylor Posts: 207
    edited 2009-04-25 17:43
    Both of those programs worked! Thank you guys!

    However do you know how they got the programs to sing? Like the "seven" song?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dan Taylor
Sign In or Register to comment.