** Sorry, I first posted in the PicBasic, but the post did not show up. Also, this forum has more activity.

I am fading on/off a Luxeon LED driver using a 12F683.
I need it to fade on, stay on for 1 second, then fade off and stay off for 1 second, and then repeats the cycle.

I can't figure out how to use PWM, so I used HPWM. After it fades on, it will then shuts off and then fades on couple more times. It then fades off and then does some random things.

Please point out what I am doing wrong and add/remove anything neccesary.
I am not a programmer so I am learning as I go. I have looked at all the help and examples I could find, but still can't figure it out.

Here's the code:

@ DEVICE PIC12F683,MCLR_OFF ' Disable external MCLR
TRISIO = %00000000
'ansel = %0000001
LED var gpio.2
TurnOn var byte
x var word
Counter var word

TurnOn=%0

led=!turnon

ProgramLoop:
gosub dimon
led=turnon
pause 1000
gosub dimoff
led=!turnon
pause 1000

goto programloop:



DimOff:
led=!turnon
For x = 0 to 1023
Hpwm 0, x, 5000
led=!turnon
pause 50
next x
Hpwm 0, 0, 0
led=!turnon
return

DimOn:
for x = 1023 to 0 step -1
Hpwm 0, x, 5000
led=!turnon
pause 50
next x
Hpwm 0, 0, 0
led=turnon
return