I have and ADC input and two resistor network driving it, so when no button pressed, adc reads 255. On button 1 it returns 128 and on button 2 it returns 0.
Both buttons are used to control same variable value, one increases it, another one decreases. User can either keep button pressed for variable to change, or use short presses to change it. The problem is that when user keeps button pressed, value should not increase too rapidly, user should be able to see changes on display and react in time. Very basically, code looks like this:
This works fine if user presses button and keeps holding it - pause 100 statement ensures that variable does not change too fast. But here comes the problem - if user uses short press, he might press it right during PAUSE 100 statement, there will be no response from the system, so it will appear to him as lagging.Code:MAINCODE: ADCIN 0,X IF X=128 THEN Y=Y+1 IF X=0 THEN Y=Y-1 GOSUB DISPLAY PAUSE 100 GOTO MAINCODE
The obvious fix would be to add a loop, and move PAUSE statement into it, with lower value, to reduce the lag, like this:
But this also does not works properly - depending on how long user pressed the buttons, he's getting final result after he releases the key.Code:MAINCODE: FOR Z=1 TO 100 ADCIN 0,X IF X=128 THEN Y=Y+1 IF X=0 THEN Y=Y-1 IF X=255 THEN GOTO POINTCHECK PAUSE 1 NEXT POINTCHECK: GOSUB DISPLAY GOTO MAINCODE
Any ideas?
Meanwhile, my nixie clock thread seems to be gone, so I'm posting picture of freshly developed model here- Runs completely on PBP, using 16F887, about 7K of code.
![]()


- Runs completely on PBP, using 16F887, about 7K of code.


Bookmarks