Shop OBEX P1 Docs P2 Docs Learn Events
lil program help.. — Parallax Forums

lil program help..

okemoabeokemoabe Posts: 12
edited 2010-04-01 17:48 in BASIC Stamp
I have designed a countdown device and have already wrote functions,·'highTone' , 'lowTone' and 'Vibrate' for it.

I need someone to sample me a BS2 coding idea·that·will make the device·to;

···--·produce 'lowTone'·from·count=1500 down to count=700 and then

·· -- make ('highTone'·+ 'Vibrate') at·count < 700.

Using IF, THEN, WHILE, FOR , NEXT, DO UNTIL·etc for PBASIC is a big problem for me as the logic ended up giving me a deadlock now.

Thanx in advance

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2010-04-01 06:09
    FOR count = 1500 to 700
     GOSUB lowTone
    NEXT
    GOSUB highTone
    


    or
    IF count < 1501 AND count > 699 THEN
     GOSUB lowTone
    ELSEIF count < 700 THEN
     GOSUB highTone
    ENDIF
    



    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.

    Post Edited (W9GFO) : 4/1/2010 6:17:07 AM GMT
  • okemoabeokemoabe Posts: 12
    edited 2010-04-01 10:55
    Thanx a lot this worked, but the hardest part for me is to output 'highTone' and 'Vibrate' at the same time.

    Can u show me how to run them concurrently with 'Vibrate' at count < 700...
  • Spiral_72Spiral_72 Posts: 791
    edited 2010-04-01 14:30
    okemoabe said...
    Thanx a lot this worked, but the hardest part for me is to output 'highTone' and 'Vibrate' at the same time.

    Can u show me how to run them concurrently with 'Vibrate' at count < 700...


    What is vibrate? Is it a typical DC motor with a counterweight? Or something else?

    If it's just a DC motor, you'll obviously need at least a trasnsistor or relay to drive it off one BS pin. Then you'd just turn on the pin with OUT and then gusub hightone.

    The pin stays ON, while your hightone routine oscillates the speaker.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "puff"...... Smile, there went another one.
  • okemoabeokemoabe Posts: 12
    edited 2010-04-01 17:48
    ok, understood...
Sign In or Register to comment.