On the following code, which the 100% i took it from the link you already gave me, i manage to place my won PWM code.

The problem is that i cannot make the LED to stay at the specific brightness i gave to the PWM.

Also at the moment it is also difficult for me to place more than one britghness.

As i told you i would like to make the button to control one led but when i press once the button to have 10% of brightness then press again and have 50% and then pressed again 100%.

If there is any help for this please, and i will keep trying to understand better the sequence of debounch.

thank you again for your help.

Best regards.

INCLUDE "bs1defs.bas"

DEFINE OSC 4


cnt VAR BYTE
delay var byte

boton VAR GPIO.2
led VAR GPIO.1

ANSEL = 0 '12F675 for test
CMCON = 7
OPTION_REG.7= 0 'Pullups enabled
WPU = %00000100

steps VAR WORD
cycles CON 2

cnt = 0
GPIO = %00000110 ' Nosurprise startup ...
TRISIO = %00000100 ' GP2 as input and set GP 0,1,3,4,5 as outputs

'************************************************* *****************************
Detect: 'Button presses W/Debounce
'
delay = 0
BUTTON Boton ,1,255,0,delay,0,pressed
'Pin,Down,Delay,Rate,BVar,Action,Label
' Slow Things down
GOTO Detect
'************************************************* *****************************
Pressed: ' Some > 10ms press detected
IF cnt <=1 Then 'tocount uptu 3, bigger values will add up.

cnt = cnt + 2

ELSE

cnt = 0
For steps=0 TO 100
PWM led,steps,cycles
Next
'in here what can i type in order the LED to stay at the specific brightness???
ENDIF

WHILE !Boton : WEND ' Wait Boton release !!!
goto detect

END