Hi Brian,
Me again.
Let me know if I'm giving too many answers ...
Try this on for sizeCode:WriteDelay CON 2000 ; ms But VAR PORTB.0 ; The Button LED1 VAR PORTB.1 ; Read indicator LED2 VAR PORTB.2 ; Write indicator DOWN CON 0 ; input state when button is DOWN DelayCount VAR WORD ; Write delay Counter Main: GOSUB CheckButton Goto Main CheckButton: IF But = Down then DelayCount = 0 PAUSE 20 ; debounce While But = Down PAUSEUS 980 DelayCount = DelayCount + 1 IF DelayCount >= WriteDelay then ; Write detected ; ---- do the Write operation here ---- TOGGLE LED2 ; ------------------------------------- While But = DOWN : Wend ; wait for button release PAUSE 20 ; debounce RETURN ENDIF WEND ; button was released before timeout ; ---- do the Read operation here ---- TOGGLE LED1 ; ------------------------------------ PAUSE 20 ; debounce ENDIF RETURN





Bookmarks