Shop OBEX P1 Docs P2 Docs Learn Events
Event is triggered once, even if the button stays pressed indefinately inside the main do...loop — Parallax Forums

Event is triggered once, even if the button stays pressed indefinately inside the main do...loop

This might seem like an easy question to some, and I do have a solution to my own question but I just believe that there must be a more efficient way to get the same result

' {$STAMP BS2p}
' {$PBASIC 2.5}

'--variables
key0 VAR Bit
key0c VAR Nib

DO
IF IN0=1 THEN
key0=1
key0c=key0c+1
ELSE
key0=0
key0c=0
ENDIF

IF key0=1 AND key0c=1 THEN
DEBUG "button 1 is pressed",CR
ENDIF
IF IN0=1 AND key0c=15 THEN
key0c=2
ENDIF
loop

Comments

Sign In or Register to comment.