Code:
reader:
adcin 0,Z
pause 100
IF Z>100 AND Z<130 THEN I=I+5
IF Z<100 THEN I=I-5
if i>255 then i=255
if i<5 then i=0
HPWM 2,I,10000
XY=I
gosub decoder
goto reader
Here is the simple code, the part if i>255 then i=255 works fine, but the part if i<5 then i=0 does not, because when i value goes below 0, it does not go below zero, it goes to 65535 and so on, completely messing whole code. Any ideas?