Hi,

I'm in the process of developing my LED Aquarium light controller a stage further and smoothing out the pulse width modulation by using 0 - 4095 steps rather than the current 255 setps. I have the leds fading nicely when using preset hard coded values, but I want to be able to program the maximum setting for brightness via the LCD as a percentage between 0 and 100 %. When I used 255 steps the following code worked

Code:
brightness:
 
Lcdout $FE,2
LCDOUT $FE,$80,"Set Max Brightness"
IF H_butt = 0 THEN GOSUB up
IF M_butt = 0 THEN GOSUB down
If (maxbright * 100)/255 = 100 then
LCDOUT $FE,$C0,"Channel 1 "
LCDOut $FE,$D4,dec3 (maxbright *100)/255,"%"
endif

If (maxbright * 100)/255 =0 or (maxbright * 100)/255 <10 then
LCDOUT$FE,$C0,"Channel 1 "
LCDOut $FE,$D4,dec1 (maxbright *100)/255,"% "
endif

if (maxbright * 100)/255 >=10 and (maxbright * 100)/255 <100 then
LCDOUT$FE,$C0,"Channel 1 "
LCDOut $FE,$D4,dec2 (maxbright *100)/255,"%   "
endif
    B_max = maxbright 
write 8,b_max      
    
If S_butt = 0 then
    pause 200 
    goto brightness2
endif 
goto brightness
But I'm stumped trying to convert this to use 4095 steps. Replacing the 255 with 4095 seemed the logical answer, but that didn't work. Changing the < = or > values (ie 10% would be 409.5) didn't work either.

Any suggestions ?