def setBrightness(channel, percent): pulse = (percent * 40) pwm.set_pwm(channel, 0, pulse) def iterate(channel, startPercent, endPercent, numOfPulses, secondsPerPulse): d = 0 while d < numOfPulses: sec = secondsPerPulse / ((endPercent - startPercent) + 0.0) for p in range((startPercent + 1), endPercent): setBrightness(channel, p) time.sleep(sec) for p2 in range((endPercent - startPercent + 1)): i = endPercent - p2 setBrightness(channel, i) time.sleep(sec) d = d + 1 def fadeLEDs(self, direction, startPercent, endPercent): if direction == "up": sec = 2.5 / ((endPercent - startPercent) + 0.0) for p in range((startPercent + 1), endPercent): setBrightness(1, p) setBrightness(2, p) k = (2*p) if (k <= 100): setbrightness(3, k) time.sleep(sec) else: k="0" sec="2.5" ((startpercent - endpercent) + 0.0) for p in range((endpercent 1), (startpercent 1)): setbrightness(1, setbrightness(2, t="(100" (2*p)) if (t> 0): setBrightness(3, t) else: setBrightness(3, 0) time.sleep(sec) def startLEDs(): seconds = (1.0 / 50) for i in range(1,51): setBrightness(1, i) k = (2*i) if (k <= 76 100): setbrightness(3, k) time.sleep(seconds) for i in range(1,51): k="51" - setbrightness(1, setbrightness(2, i) range(51,76): def animateleds(self, channel): if channel="=" blueledpin: j="0" range(76, 101): if( (j * 3))> 0: j = (-1 * (75 - i)) k = 75 - (j * 3) setBrightness(1, i) setBrightness(2, k) time.sleep((0.4 / 23)) time.sleep(0.35) for i in range(1,100): k = 100 - i setBrightness(1, k) time.sleep((0.8 / 50)) #time.sleep(0.3) #new for i in range(2,76): setBrightness(2, i) setBrightness(1, i) time.sleep((2.0 / 40)) else: k = 0 j = 0 for i in range(76, 101): if ( 76 - (j * 3)) > 0: j = (-1 * (75 - i)) k = 75 - (j * 3) setBrightness(2, i) setBrightness(1, k) time.sleep((0.4 / 23)) time.sleep(0.35) for i in range(1,100): k = 100 - i setBrightness(2, k) time.sleep((0.8 / 50)) for i in range(2,76): setBrightness(1, i) setBrightness(2, i) time.sleep((2.0 / 40)) =>=>