Shop OBEX P1 Docs P2 Docs Learn Events
Paintball — Parallax Forums

Paintball

ArchiverArchiver Posts: 46,084
edited 2004-01-10 06:09 in General Discussion
Hi, just joined here, and i've done alot of TRUBasic programming, but
nothing here on a basic stamp yet. If there are any similar programs
you could email me, or if you have any advice for how to put it
together, feel free to let me know. What i'm trying to build is
a "bomb" to use in paintball, similar to the game "Counter-strike" on
PC and Xbox. Don't worry, no dangers in this one, it will simply run
a relay to a small siren to signal the "bomb" went off and the game
is over. Here's what the program needs to do:

It needs to recieve input from 3 switches, and give output to an
innovation first Spike relay. With the switches, the "Arm" switch
must be held for 10 seconds to turn on the "bomb". A counter will
count down from 100 seconds, while telling the relay to beep the
siren again and again, with the time gap in between beeps getting
smaller to match the timer. Now, the "Disarm" button must be held for
10 seconds to turn off the "bomb", which then results in the relay
beeping the siren in some sort of pattern to let everyone within
earshot know that it is disarmed. The 3rd button is an instant
disarm, for in case the person disarming is the one on their team (or
has access to the person) with the "disarming tool", most likely a
headphone plug, which completes its switch circuit when installed.
This is all built onto a Board of Education with a basic stamp 2 v1.
The unit itself will be about the size of a small lunchbox. Thanks
for any and all help you guys can give me.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2004-01-09 15:58
    Neal,

    Should be easy beans. Look up the "button" command for your switches. As the
    basic Stamp does not have a timer, you will need to use program loops and
    pauses to effect the timing you want.

    In pseudo code, something like:


    main:

    if button1 = high then
    pause 10
    if button1 = high then
    gosub Armed
    endif
    endif

    goto main


    Armed:

    for i = 0 to 99
    sound alarm
    pause X
    next

    if button3 = high then
    pause 10
    if button3 = high then
    sound alarm
    return
    else
    goto Armed
    endif

    if button2 = high then
    sound alarm
    return
    endif

    return

    This code is very crude, and there are better ways of doing it I am sure,
    but it is a start.

    Hope this helps,

    Jonathan

    www.madlabs.info


    Original Message
    From: "Neal Muzzy" <neal_muzzy@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, January 08, 2004 7:27 PM
    Subject: [noparse][[/noparse]basicstamps] Paintball "bomb" program


    > Hi, just joined here, and i've done alot of TRUBasic programming, but
    > nothing here on a basic stamp yet. If there are any similar programs
    > you could email me, or if you have any advice for how to put it
    > together, feel free to let me know. What i'm trying to build is
    > a "bomb" to use in paintball, similar to the game "Counter-strike" on
    > PC and Xbox. Don't worry, no dangers in this one, it will simply run
    > a relay to a small siren to signal the "bomb" went off and the game
    > is over. Here's what the program needs to do:
    >
    > It needs to recieve input from 3 switches, and give output to an
    > innovation first Spike relay. With the switches, the "Arm" switch
    > must be held for 10 seconds to turn on the "bomb". A counter will
    > count down from 100 seconds, while telling the relay to beep the
    > siren again and again, with the time gap in between beeps getting
    > smaller to match the timer. Now, the "Disarm" button must be held for
    > 10 seconds to turn off the "bomb", which then results in the relay
    > beeping the siren in some sort of pattern to let everyone within
    > earshot know that it is disarmed. The 3rd button is an instant
    > disarm, for in case the person disarming is the one on their team (or
    > has access to the person) with the "disarming tool", most likely a
    > headphone plug, which completes its switch circuit when installed.
    > This is all built onto a Board of Education with a basic stamp 2 v1.
    > The unit itself will be about the size of a small lunchbox. Thanks
    > for any and all help you guys can give me.
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Yahoo! Groups Links
    >
    > To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    > To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    > Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-09 16:26
    You can add a counter value, and when the value gets to a certain value
    toggle a pin on and off. This can be used for a blinking led<G>.

    Original Message
    From: Jonathan Peakall [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=fnQ02zICztrb14Oq8potQhvEsAsqRqDgFh-b5-eznjgjNI01mrVCfiaTWEAhC6inlCFMNanylBhuM14]jpeakall@p...[/url
    Sent: Friday, January 09, 2004 10:59 AM
    To: basicstamps@yahoogroups.com
    Subject: Re: [noparse][[/noparse]basicstamps] Paintball "bomb" program


    Neal,

    Should be easy beans. Look up the "button" command for your switches. As the
    basic Stamp does not have a timer, you will need to use program loops and
    pauses to effect the timing you want.

    In pseudo code, something like:


    main:

    if button1 = high then
    pause 10
    if button1 = high then
    gosub Armed
    endif
    endif

    goto main


    Armed:

    for i = 0 to 99
    sound alarm
    pause X
    next

    if button3 = high then
    pause 10
    if button3 = high then
    sound alarm
    return
    else
    goto Armed
    endif

    if button2 = high then
    sound alarm
    return
    endif

    return

    This code is very crude, and there are better ways of doing it I am sure,
    but it is a start.

    Hope this helps,

    Jonathan

    www.madlabs.info


    Original Message
    From: "Neal Muzzy" <neal_muzzy@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: Thursday, January 08, 2004 7:27 PM
    Subject: [noparse][[/noparse]basicstamps] Paintball "bomb" program


    > Hi, just joined here, and i've done alot of TRUBasic programming, but
    > nothing here on a basic stamp yet. If there are any similar programs
    > you could email me, or if you have any advice for how to put it
    > together, feel free to let me know. What i'm trying to build is a
    > "bomb" to use in paintball, similar to the game "Counter-strike" on PC
    > and Xbox. Don't worry, no dangers in this one, it will simply run a
    > relay to a small siren to signal the "bomb" went off and the game is
    > over. Here's what the program needs to do:
    >
    > It needs to recieve input from 3 switches, and give output to an
    > innovation first Spike relay. With the switches, the "Arm" switch must
    > be held for 10 seconds to turn on the "bomb". A counter will count
    > down from 100 seconds, while telling the relay to beep the siren again
    > and again, with the time gap in between beeps getting smaller to match
    > the timer. Now, the "Disarm" button must be held for 10 seconds to
    > turn off the "bomb", which then results in the relay beeping the siren
    > in some sort of pattern to let everyone within earshot know that it is
    > disarmed. The 3rd button is an instant disarm, for in case the person
    > disarming is the one on their team (or has access to the person) with
    > the "disarming tool", most likely a headphone plug, which completes
    > its switch circuit when installed. This is all built onto a Board of
    > Education with a basic stamp 2 v1. The unit itself will be about the
    > size of a small lunchbox. Thanks for any and all help you guys can
    > give me.
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject
    > and
    Body of the message will be ignored.
    >
    >
    > Yahoo! Groups Links
    >
    > To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    > To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    > Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
    >


    To UNSUBSCRIBE, just send mail to:
    basicstamps-unsubscribe@yahoogroups.com
    from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.


    Yahoo! Groups Links

    To visit your group on the web, go to:
    http://groups.yahoo.com/group/basicstamps/

    To unsubscribe from this group, send an email to:
    basicstamps-unsubscribe@yahoogroups.com

    Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-09 18:46
    Thanks a ton, that will help me alot on my way to making this work.
    Here's what i've got so far:

    '{$STAMP BS2}
    main:

    IF button1 = HIGH THEN
    PAUSE 10
    IF button1 = HIGH THEN
    GOSUB Armed
    endif
    endif

    GOTO main


    Armed:

    FOR i = 0 TO 99
    PAUSE 1
    NEXT i

    FOR b = 0 TO 200 'must be changed to match up with detonation
    Spike HIGH
    PAUSE .1
    Spike LOW
    PAUSE (99-i)/5
    NEXT b

    IF i = 99 THEN
    Spike HIGH
    PAUSE 10
    Spike LOW
    GOTO END

    IF button3 = HIGH THEN
    PAUSE 10
    IF button3 = HIGH THEN
    sound alarm
    RETURN
    else
    GOTO Armed
    endif

    IF button2 = HIGH THEN
    GOSUB Disarmed
    RETURN
    endif

    Disarmed:

    FOR a = 0 TO 20
    spike HIGH
    PAUSE .2
    spike LOW
    PAUSE .5
    spike HIGH
    PAUSE .5
    spike LOW
    PAUSE .5
    NEXT a
    GOTO end

    RETURN

    END

    okay, it's probably alot of misuse of wording and formats, but I
    think it's closer to the the finished product.
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-09 22:43
    Okay, here's the program revised alot better, hopefully it's getting
    close. Copy and past my program into your editor to see which parts
    come up blue, and which don't, such as the endif statements (not used
    to this language of basic). Any translations for these would be
    greatly appreciated. Also, i need to rig up 3 seperate on/off
    switches and an output for an IFI spike relay, so if you know any
    copy/paste solutions for that, i would be greatly thankful.

    '{$STAMP BS2}
    main:

    IF button1 = high THEN
    FOR z = 1 TO 10
    IF button1 = HIGH THEN
    PAUSE 1
    endif
    if BUTTON1 = LOW THEN
    let z = 1
    GOTO main
    endif
    NEXT z
    IF button1 = HIGH THEN
    GOSUB Armed
    endif
    endif

    GOTO main


    Armed:

    FOR i = 0 TO 99
    PAUSE 1
    NEXT i

    FOR b = 0 TO 200 'must be changed to match up with detonation
    Spike HIGH
    PAUSE .1
    Spike LOW
    PAUSE (99-i)/5
    NEXT b

    IF i = 99 THEN
    Spike HIGH
    PAUSE 10
    Spike LOW
    GOTO END

    IF BUTTON2 = HIGH THEN
    FOR y = 1 TO 10
    IF BUTTON2 = HIGH THEN
    PAUSE 1
    endif
    IF BUTTON2 = LOW THEN
    let y = 1
    GOTO main
    endif
    NEXT y
    IF BUTTON2 = HIGH THEN
    GOSUB Disarmed
    endif
    endif

    IF BUTTON3 = HIGH THEN
    GOSUB Disarmed
    RETURN
    endif

    Disarmed:

    FOR a = 0 TO 20
    spike HIGH
    PAUSE .2
    spike LOW
    PAUSE .5
    spike HIGH
    PAUSE .5
    spike LOW
    PAUSE .5
    NEXT a
    GOTO END

    RETURN

    END
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-10 05:00
    Neal,

    Add the directive:

    '{$PBASIC 2.5}

    And use the latest editor. The endif's look ok to me. Of course, the vars
    aren't declared, so it won't tokenize. Looks like progress though!

    Jonathan

    www.madlabs.info

    Original Message
    From: "Neal Muzzy" <neal_muzzy@y...>
    To: <basicstamps@yahoogroups.com>
    Sent: Friday, January 09, 2004 2:43 PM
    Subject: [noparse][[/noparse]basicstamps] Re: Paintball "bomb" program


    > Okay, here's the program revised alot better, hopefully it's getting
    > close. Copy and past my program into your editor to see which parts
    > come up blue, and which don't, such as the endif statements (not used
    > to this language of basic). Any translations for these would be
    > greatly appreciated. Also, i need to rig up 3 seperate on/off
    > switches and an output for an IFI spike relay, so if you know any
    > copy/paste solutions for that, i would be greatly thankful.
    >
    > '{$STAMP BS2}
    > main:
    >
    > IF button1 = high THEN
    > FOR z = 1 TO 10
    > IF button1 = HIGH THEN
    > PAUSE 1
    > endif
    > if BUTTON1 = LOW THEN
    > let z = 1
    > GOTO main
    > endif
    > NEXT z
    > IF button1 = HIGH THEN
    > GOSUB Armed
    > endif
    > endif
    >
    > GOTO main
    >
    >
    > Armed:
    >
    > FOR i = 0 TO 99
    > PAUSE 1
    > NEXT i
    >
    > FOR b = 0 TO 200 'must be changed to match up with detonation
    > Spike HIGH
    > PAUSE .1
    > Spike LOW
    > PAUSE (99-i)/5
    > NEXT b
    >
    > IF i = 99 THEN
    > Spike HIGH
    > PAUSE 10
    > Spike LOW
    > GOTO END
    >
    > IF BUTTON2 = HIGH THEN
    > FOR y = 1 TO 10
    > IF BUTTON2 = HIGH THEN
    > PAUSE 1
    > endif
    > IF BUTTON2 = LOW THEN
    > let y = 1
    > GOTO main
    > endif
    > NEXT y
    > IF BUTTON2 = HIGH THEN
    > GOSUB Disarmed
    > endif
    > endif
    >
    > IF BUTTON3 = HIGH THEN
    > GOSUB Disarmed
    > RETURN
    > endif
    >
    > Disarmed:
    >
    > FOR a = 0 TO 20
    > spike HIGH
    > PAUSE .2
    > spike LOW
    > PAUSE .5
    > spike HIGH
    > PAUSE .5
    > spike LOW
    > PAUSE .5
    > NEXT a
    > GOTO END
    >
    > RETURN
    >
    > END
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and
    Body of the message will be ignored.
    >
    >
    > Yahoo! Groups Links
    >
    > To visit your group on the web, go to:
    > http://groups.yahoo.com/group/basicstamps/
    >
    > To unsubscribe from this group, send an email to:
    > basicstamps-unsubscribe@yahoogroups.com
    >
    > Your use of Yahoo! Groups is subject to:
    > http://docs.yahoo.com/info/terms/
    >
    >
    >
    >
  • ArchiverArchiver Posts: 46,084
    edited 2004-01-10 06:09
    Well, I got it.

    I worked all evening to crank this out, with lots of trouble figuring
    out a way to keep a failed disarm attempt from restarting the armed
    countdown. I've been using an LED hooked up where the speaker would
    be, and even then, i plan on eventually replacing the simple speaker
    high/low with commands going out to a spike relay, once i know how to
    set that up. But for now, the LED has shown me that, using a jumper
    wire to immitate switches being held, it works exactly how i want it
    to. Here's the program:

    '{$STAMP BS2} Program framework by Gary Denison
    ' Revisions by Neal Muzzy


    OUTPUT 2
    A VAR Word
    B VAR Word
    C VAR Word
    D VAR Word
    E VAR Word
    Main:
    A=1
    IF (IN3 = 1) THEN arm
    PAUSE 10
    GOTO main

    arm:
    FOR B = 1 TO 10
    IF (IN3 = 0) THEN main
    PAUSE 1000
    ENDIF
    NEXT
    GOTO armed

    armed:
    FOR A = D TO 1000
    D=D+1
    HIGH 2 'BLINK
    PAUSE 20 'BLINK
    LOW 2 'BLINK
    PAUSE (1000-D)'BLINK
    E=E+1
    IF (IN4 = 1) THEN GAP
    E = 0

    GAP:
    IF E=10 THEN Disarmed
    IF (IN5 = 1) THEN Disarmed
    IF C<1000 THEN armed
    GOTO detonate

    disarmed:
    FOR C = 1 TO 100
    HIGH 2
    PAUSE 100
    LOW 2
    PAUSE 400
    HIGH 2
    PAUSE 500
    LOW 2
    PAUSE 400
    NEXT
    GOTO main

    detonate:
    HIGH 2
    PAUSE 10000
    LOW 2
    GOTO main
Sign In or Register to comment.