sure it can be done.Heres an extract of working code which hopefully demonstartes what i mean. Its a piece of code which makes the LEDs look as if the are fading on and off. I would like to step to the next LED immediately the button is pushed, no matter at what position the fading is at. Can this be done?
Code:start: Select Case PushHowManyTimes case 1 GetOut = 0 gosub FadeRed Case 2 GetOut = 0 gosub FadeGreen end select goto start FadeRed: bright = 0 while (Bright !=255) and (GetOut=0) PWM Red,Bright,1 bright = bright + 1 wend while (bright !=0) and (getout = 0) PWM Red,Bright,1 bright=bright - 1 wend return FadeGreen: bright = 0 while (Bright !=255) and (GetOut=0) PWM Green,Bright,1 bright = bright + 1 wend while (bright !=0) and (getout = 0) PWM Green,Bright,1 bright=bright - 1 wend return ' Interrupt handler stuff here ' DISABLE ' Disable interrupts in handler ProcedureSwitcher: INTCON.7 = 1 'disable all interrputs PORTC=0 ' reset output to PORTC DelayLoop=Delay ' to exit the delay loop GetOut = 1 ' to get out of the entire PWM loops PushHowManytimes=PushHowManytimes+1 ' Changing task If PushHowManytimes=3 then PushHowManytimes=1 While PORTB.0 = 0 ' waiting untill wend ' push-button is release pause 100 ' debounce time INTCON = %10010000 ' Enable RB0 interrupt ' reset RB0 interrupt flag RESUME ' Return to main program ENABLE ' Enable interrupts after handler




Bookmarks