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

Use of BUTTON command

patsepatse Posts: 3
edited 2014-02-26 10:11 in BASIC Stamp
Hello,

I have a problem with use of the BUTTON command.
Can it only perform an action once?

I need a debounced Pin. Everytime I press it, a number should be increased. Works well with BUTTON command - but only once!!

Can anybody help me?

Thank you!


CODE SNIPPET:

... GOTO up

buttonTest:
count = IsOn
GOTO up


up:
DO
BUTTON 14, 1, 255, 0, buttonBuffer(1), 1, buttonTest


IF (count) THEN
count = IsOff
number= number+ 1
ENDIF
LOOP

Comments

  • Hal AlbachHal Albach Posts: 747
    edited 2014-02-26 06:46
    It appears you have a variable named "count" which is a reserved word and is actually a command unless you are using BS1. Strongly suggest you change to a non-reserved name.
  • patsepatse Posts: 3
    edited 2014-02-26 08:36
    I changed the name of the variable for my code snippet. I use German names and I changed them to make them understandable for others. But thank you!
  • patsepatse Posts: 3
    edited 2014-02-26 10:11
    I think I solved the problem. It was a hardware mistake in my circuit. Input Port did not go back to 0 after pushing it down to 1.
Sign In or Register to comment.