Reading the input slowly

I wrote a basic program to get familiar with the basic atom pro. It’s suppose to light up an LED when the push button is press down and on release it turns the LED off. Well it works but it takes approximately two seconds to register if the button is pressed but its immediate turn off. Just wondering if someone can shed some light on why it takes so long to turn on and if there’s a solution to speed it up. It’s not the LED, I entered a debug line to see if it’s going into the IF statement as soon as I press the button and its not. Thanks

LOW P0
INPUT P4
MAIN
IF IN4 = 1 THEN
high P0
debug [bin IN4]

ELSE
LOW P0
ENDIF
GOTO MAIN
End1

looked at some simple code I have and you should try assigning the input to a variable of type bit… like this

[code]MYSW VAR BIT

LOW P0

MAIN
MYSW = IN4

IF MYSW = 1 THEN
high P0
debug [bin MYSW]

ELSE
LOW P0
ENDIF

GOTO MAIN

END[/code]
now as to the “why” of it… no idea… I gave up trying to figure out odd stuff on BAP awhile ago. :unamused: sorry I don’t have a better answer.

Ok gave that a try and it sped it up a bit, sorry for the pun. It still delays for a sec.

Did you take the debug statement out? Other than that it sounds like a real good performance question for the basic micro guys. :wink:

I tried this code and it works great without any delays. (even with the debug) Which IDE are you using? I would recommend you use the latest one 8.0.1.7 which is found in this thread.

lynxmotion.net/viewtopic.php?t=3473

[code]MYSW VAR BIT

LOW P0

MAIN
MYSW = IN4

IF MYSW = 1 THEN
high P0
debug [bin MYSW]

ELSE
LOW P0
ENDIF

GOTO MAIN

END[/code]

I was also able to get this to work with no trouble.

[code]low P0

main
if in12 = 1 then
high P0
else
low P0
endif

goto main

end[/code]