Shop OBEX P1 Docs P2 Docs Learn Events
Simple Button plays a tone — Parallax Forums

Simple Button plays a tone

overlook77overlook77 Posts: 10
edited 2006-05-04 01:42 in BASIC Stamp
I have the StampWorks Kit with the professional development board and a BS2.· I am trying to learn the PBASIC language but am having trouble.· I want Button 0 to make a sound whenever you press it.· However, my code only plays the tone by itself once and the button does nothing.· Can someone correct my code?

' {$STAMP BS2}
WkSpace VAR Byte
Main:
····· BUTTON 8, 1, 0, 0, WkSpace, 1, PlayTone
· PlayTone:
··· FREQOUT 7, 250, 3000

Comments

  • overlook77overlook77 Posts: 10
    edited 2006-05-04 01:42
    Ok, I think I answered my own question...it looks like you have to put the BUTTON command in a loop. Below seems to work.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}


    Btn PIN 8

    btnWrk VAR Byte

    Main:
    BUTTON Btn, 0, 200, 20, btnWrk, 0, No_Press
    FREQOUT 7, 150, 2000

    No_Press:
    GOTO Main
Sign In or Register to comment.