Shop OBEX P1 Docs P2 Docs Learn Events
been traveling all day, out of virtual gas. — Parallax Forums

been traveling all day, out of virtual gas.

Last~Cell~LeftLast~Cell~Left Posts: 10
edited 2006-09-03 16:03 in BASIC Stamp
I think I am using the counter var byte for wrong reasons, I am beginning to think this way isn't going to work.

Been online all day and at two books stores with no luck of any basic stamp II books " other then robot books "

What I am trying to figure out,

I have two homework stamp boards,

a)·board has all the·" brain "·code / input /output
b)·board has all the out-put / input codes for random acts of operation.

A is monitoring a push button switch, I am trying to figure out how to run a 1 to 3 counter?, so that if the button is pushed 3 times, it will trigger an output on board·A that I will then run through a board level gate to trip an input on board B and from there, board B is responsible for the results.

But if the 1 to 3 counter does not get to 3 before the program ends " cause of user lose " then it resets the counter when the·program is reset.

Any direction or web page suggestion, or whatever you could offer, would be of great help .

thanks in advance.

kyle·

Comments

  • FranklinFranklin Posts: 4,747
    edited 2006-09-03 02:40
    What do you mean by "the program ends"? That in itself would reset the counter. If you mean to receive three pushes within a time frame then you would start a timer and when the timer runs out you would reset the push variable.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Last~Cell~LeftLast~Cell~Left Posts: 10
    edited 2006-09-03 03:46
    Well my mental to text skills seem to be lacking this evening, need more caffine. lol

    I think the easiest way to accomplish this for now, instead of worring about an internal counter, is to

    with each stage, if the stages are completed in sequence, then I will just add a high to a open output, so if there are 3 passed stages of events, then three outputs will be constant high ( until reset ). with some AND Gates I can have a ( final)output only when the three are high then the AND gate output activates to trip a gate to the other stamps input.

    I figured I would collect the three outputs from the first stamp and run them through AND gates to bring them down to one high into the other stamp instead wasting three pins as three inputs,

    I think I was trying to see if I could do this event " internally " without using many componets and without tying up to many pins for outputs.

    If this makes sense?
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-09-03 04:24
    Kyle -

    Is this what you're trying to do?

    Check-Button:

    If In0 = 1 GOSUB Total 'See if input button on Pin Port 0 is pressed
    'Do other things
    GOTO Check-Button.

    Total:

    Ctr = Ctr + 1 'Increment counter
    If Ctr <> 3 THEN GOTO Check-Button 'Is counter = 3?
    Ctr = 0 'If so, reset the counter and
    HIGH 6 'Set Pin Port 6 HIGH
    GOTO Check-Button 'Continue on

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Last~Cell~LeftLast~Cell~Left Posts: 10
    edited 2006-09-03 16:03
    Guys thanks for your help !

    Last night after my last post, I was too lazy to look in my junk bins for some AND gate chips, So I sat down and since I had issues with the counter code,

    I decided to use a " latching· " code system.· Where it had no choice but to follow a goto pattern.· I mapped it out by telling it, you can do this once, but you can not do " this·" until this exists already.,

    It may be OVER kill in the valuable space limits of stamp code, But at least it let me sleep last night. lol

    Bruce, thank you for that code,· I will copy it and see how I can make it work, if it saves me lines of code IT is worth it,

    thanks again!

    Post Edited (Last~Cell~Left) : 9/3/2006 4:19:15 PM GMT
Sign In or Register to comment.