Shop OBEX P1 Docs P2 Docs Learn Events
Anybody have a cool tune for a piezo speaker on a bs2 board? — Parallax Forums

Anybody have a cool tune for a piezo speaker on a bs2 board?

AndyGAndyG Posts: 1
edited 2005-04-14 01:43 in BASIC Stamp
Anybody have a cool tune for a piezo speaker on a bs2 board?
Thanks
Andy

Comments

  • dandreaedandreae Posts: 1,375
    edited 2005-04-13 18:08
    Hello,

    I have attached some various codes for you to try.

    Dave


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave Andreae

    Tech Support
    dandreae@parallax.com
    www.parallax.com
  • davecdavec Posts: 10
    edited 2005-04-13 19:54
    i also like the nokia ring tone player MicroMusicWithRtttl.bs2 from Wamv2_2.pdf. lot's of ringtones on the web.

    RTTTL_File DATA "simpsons:d=4,o=5,b=160:c6,e6,f#6,8a6,g6,e6,c6,8a,8f#,8f#,8f#,2g,8p,8p,8f#,8f#,8f#,8g,a#,8c6,8c6,8c6,c6"
  • Joe FishbackJoe Fishback Posts: 99
    edited 2005-04-14 01:09
    Dave,

    I can get the program you posted "piezo pal.bs2" to run, but I have some questions about its code. The last code part is as follows:


    SHOW4: DEBUG "Heart and Soul",CR

    LOOP 'Get the next note to be played

    Song4
    LOOKUP indx,[noparse][[/noparse] C5, R, C5, R, C5, R, C5,BE4, A4,BE4, C5, D5,R, C5, E5, R, E5, R, E5,0],note
    LOOKUP indx,[noparse][[/noparse]450,50,400,50,750,90,200,300,200,300,200,300,5,200,450,30,450,50,800],dura
    IF note = 0 THEN DELAY 'it.
    IF note = R THEN REST
    FREQOUT 4,dura,note
    NXT
    indx = indx + 1
    GOTO LOOP
    REST
    PAUSE dura
    GOTO NXT

    DELAY
    note = 0
    dura = 0
    indx = 0
    PAUSE 200
    STOP

    There is not a colon ([noparse]:)[/noparse] after the "labels" nxt, rest & delay. I thought you had to have a colon after labels? This works ptogram runs, but is it just not "good" coding? Your comments about how this code is written would help me in my own coding.

    Joe Fishback
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-04-14 01:43
    "Good" coding suggests using colons after labels, and when using version 2.5 syntax in the BASIC Stamp IDE colons after labels are required.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
Sign In or Register to comment.