with the existing stuff, try this one
Code:
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
ANSEL.0 = 0 ' Set GPIO.0 to digital
CMCON = 7 ' PortA Digital inputs
VRCON = 0 ' Voltage reference disabled
TRISIO.0 = 0 ' Set GPIO.0 to output.
GPIO.0 = 0 '
LED var GPIO.0
I var byte
GetOut var bit
main:
for i = 1 to 254
Pwm GPIO.0,i,1
if i=253 then
i=254
GetOut=1
endif
next i
if Getout=1 then down
goto main
down:
getout=0
for i = 254 to 1 step -1
Pwm GPIO.0,i,1
if i=2 then
i=1
GetOut=1
endif
next i
if Getout=1 then main
goto down
and to make something usefull with the GetOut flag, use the following. Tested and work at treat. OK i'd modified the hardware assignement to fit to one of my already build board here
Code:
@ __CONFIG _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON
ANSEL = 0 ' Set GPIO.0 to digital
CMCON = 7 ' PortA Digital inputs
VRCON = 0 ' Voltage reference disabled
TRISIO = $0F ' gpio<3:0> : Input
' gpio<5:4> : Output
GPIO = 0 ' clear all outputs
LED var GPIO.5
PB var GPIO.0
I var byte
GetOut var bit
Pause 50 ' oscillator settle time...
OPTION_REG.7 =0 ' enable internal pull-up
WPU = 1 ' enable pull-up on GPIO.0 only
main:
for i = 1 to 254
Pwm led,i,1
if pb=0 then
i=254
GetOut=1
endif
next i
if Getout=1 then
while pb=0 : wend
pause 50
GETOUT=0
goto down
endif
goto main
down:
for i = 254 to 1 step -1
Pwm led,i,1
if pb=0 then
i=1
GetOut=1
endif
next i
if Getout=1 then
while pb=0 : wend
pause 50
GETOUT=0
GOTO main
ENDIF
goto down
HTH
Bookmarks