Shop OBEX P1 Docs P2 Docs Learn Events
Use of the BUTTON command — Parallax Forums

Use of the BUTTON command

hijkerhijker Posts: 10
edited 2006-09-17 20:58 in BASIC Stamp
I can't get the BUTTON command working the way I want.

What I have is 2 buttons named UP and Down.
When I press one of them a counter should count up or down.
When I fast press or use auto repeat the counter should also in/decrease.

This works so far.

But when I stop pressing the program must check the value in the counter and process it.
This part does not work.
As soon as I press the button the prog always enters this check.

Main:

BUTTON Down, 0,400, 20, ButVal, 0, NextBut
DisVal = DisVal - 1·· 'Decrease Counter
GOTO Main

NextBut:
BUTTON Up, 0,400, 20, ButVal, 0, No_Press
DisVal = DisVal + 1· 'Increase Counter
GOTO Main

No_Press:···· ' It should come here only when a button is NOT pressed after some time.· But it comes here even after 1 press and the next (fast) press is ignored.
.
.
.

IF RN = DisVal THEN Hoofd
'*
IF DisVal = 1 THEN r1

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-09-16 13:03
    Hijker -

    As far as I'm aware, EACH Button command should have it's OWN workarea ("ButVal"). Try that and see what happens.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • hijkerhijker Posts: 10
    edited 2006-09-17 07:27
    Thanks Bruce, that did not work either.
    All I want is press a button, maybe once or maybe more than once.
    After the button(s) are quiet for some time then I want process the changes.

    ·
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2006-09-17 20:58
    Hi, EveyOne

    I· want to use the Button command to keep looking to see if it PIN·gose ·low and run·ONE·routine then when it see the pin gose HIGH then run the SECOND·routine i doing a project where i will running the BS2 on battery some of the time and some of the time AC power

    How would i do this

    I·am sorry if i have HIJACK this Post i did not mean to this but this person was asking this·and this will be something that i will be doing very

    soon

    Thank for any help that you can give in this matter

    Sam
Sign In or Register to comment.