The Code didn't format properly, hopefully this will make it easier to read !!
Fading LED
RGB SequenceCode:VariableSolidColour: PWM onled,bright,10 If FuncSwitch=0 Then While FuncSwitch = 0 If Flag = 0 Then If Bright <255 Then Bright = Bright + 1 If bright = 255 Then Gosub flash EndIf If Flag = 1 Then If Bright >0 Then Bright = Bright - 1 EndIf PWM onled,Bright,10 WEnd Flag = Flag + 1 EndIf Return
My AttemptCode:RGBSequence: rainbowval=0 While (rainbowval !=255) and (getout=0) for RGBDelay = 1 to 10 gosub RGBRainbow next RGBDelay rainbowval=rainbowval+1 Wend While rainbowval and (getout=0) for RGBDelay = 1 to 10 gosub RGBRainbow next RGBDelay rainbowval=rainbowval-1 wend Return RGBRainbow: rbg=0 While (rbg<=2) and (getout=0) section = ((rainbowval + ((rbg * 2)*delta))/ delta) // 6 ' this gives ' what section ' it is in Select case section case 0 rbgarray[rbg] = (rainbowval // delta)*6 ' this is how far it ' has gone in its ' section case 1 rbgarray[rbg] = 255 case 2 rbgarray[rbg] = 255 case 3 rbgarray[rbg] = 255 - ((rainbowval //delta)*6) case 4 rbgarray[rbg] = 0 case 5 rbgarray[rbg] = 0 case 6 'this one is for pics bad math rbgarray[rbg] = 0 end select rbg=rbg+1 wend Gosub ledpwm Return ledPWM: y=0 While (y<=2) and (getout=0) Select Case y Case 0 PWM red, rbgarray[y], 1 Gosub ResetLEDs Case 1 PWM green, rbgarray[y], 1 Gosub ResetLEDs case 2 PWM blue, rbgarray[y], 1 Gosub ResetLEDs End Select y=y+1 wend Return
Many thanks for any help,Code:VariableDualColour: ' PWM onled,Brightx,1 ' PWM secondled,brightx,1 Gosub pwmdual If FuncSwitch=0 Then While FuncSwitch = 0 If Flag = 0 Then If Bright <255 Then Bright = Bright + 1 If bright = 255 Then Gosub flash EndIf If Flag = 1 Then If Bright >0 Then Bright = Bright - 1 EndIf gosub pwmdual ' PWM onled,Brightx,1 ' PWM secondled,brightx,1 WEnd Flag = Flag + 1 EndIf Return PWMDual: For z = 0 to 1 Select Case z Case 0 pwm Onled, Bright, 10 case 1 pwm secondled, bright, 10 end select next Return
Steve




Bookmarks