Shop OBEX P1 Docs P2 Docs Learn Events
program for turning on sound without interrupting lights? — Parallax Forums

program for turning on sound without interrupting lights?

MacadaciouseMacadaciouse Posts: 16
edited 2011-11-23 11:50 in General Discussion
I'd like an effect to play a message while still scrolling lights, anyone know how to run a subroutine without causing the lights to stop for the duration? My current code is below, however I'm fiarly sure the lights (dpdt relay on pin 15) will kick off when the subroutine turns on the ipod (pin 0)

[code]
' {$STAMP BS2}
' {$PBASIC 2.5}

DO
HIGH 15
PAUSE 500
LOW 15
PAUSE 500

IF IN1 = 1 THEN GOSUB sound
sound:
HIGH 0
PAUSE 200
LOW 0

[code/]

Comments

  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2011-11-23 11:15
    As the BS2 can't do more than one thing at a time, you'll be hard pressed unless you can fit the lights and sound within the same delay periods. You could likely do it with a rework of your code, but to make this type of thing easier there's a small product that does what you want:

    www.parallax.com/Store/Accessories/Sound/tabid/164/ProductID/482/Default.aspx

    As a co-processor it offloads sound generation and plays it concurrently with code running on your BS2. I'd advise a SoundPal if the coding on your BS2 will get any more elaborate than it is now.

    -- Gordon
  • tonyp12tonyp12 Posts: 1,951
    edited 2011-11-23 11:50
    Software Statemachine.
    lable
    A=A+1
    if A & %1111 =0 then xor led
    if A & %11111 =0 and in1=1 then xor sound.
    goto lable.

    I don't know basicstamps syntax so pseudo code.
    And it does not extactly do what is done in above code.
    & = BItwise AND
Sign In or Register to comment.