示例#1
0
def main():
    led1 = RGBLED(22, 24, 26)
    led2 = RGBLED(11, 13, 15)
    led3 = RGBLED(19, 21, 23)
    leds = [led1, led2, led3]
    for led in leds:
        led.redOn()
        time.sleep(1)
        led.redOff()
        led.greenOn()
        time.sleep(1)
        led.greenOff()
        led.blueOn()
        time.sleep(1)
        led.blueOff()

    led1.cleanUp()
示例#2
0
def main():
    led1 = RGBLED(22, 24, 26)
    led2 = RGBLED(11, 13, 15)
    led3 = RGBLED(19, 21, 23)
    led1.startPWM(100, 0)
    led2.startPWM(100, 0)
    led3.startPWM(100, 0)
    for i in range(0, 200):
        led1.redDutyCycle(random.randint(0, 100))
        led1.greenDutyCycle(random.randint(0, 100))
        led1.blueDutyCycle(random.randint(0, 100))

        led2.redDutyCycle(random.randint(0, 100))
        led2.greenDutyCycle(random.randint(0, 100))
        led2.blueDutyCycle(random.randint(0, 100))
        
        led3.redDutyCycle(random.randint(0, 100))
        led3.greenDutyCycle(random.randint(0, 100))
        led3.blueDutyCycle(random.randint(0, 100))
        time.sleep(2.5)
    led1.stopPWM()
    led2.stopPWM()
    led3.stopPWM()
    led1.cleanUp()
示例#3
0
def main():
    ledMap = {}
    led1 = RGBLED(22, 24, 26)
    led2 = RGBLED(11, 13, 15)
    led3 = RGBLED(19, 21, 23)
    #map the leds to their (R, G, B) duty cycle values
    ledMap[led1]=(0,0,0)
    ledMap[led2]=(0,0,0)
    ledMap[led3]=(0,0,0)
    #start led pwm
    led1.startPWM(100, 0)
    led2.startPWM(100, 0)
    led3.startPWM(100, 0)

    for i in range(0, 100):
        color1 = (random.randint(0,100), random.randint(0,100), random.randint(0,100))
        color2 = ledMap[led1]
        color3 = ledMap[led2]
        #set all of the duty cycles
        led1.redDutyCycle(color1[0])
        led2.redDutyCycle(color2[0])
        led3.redDutyCycle(color3[0])
        led1.greenDutyCycle(color1[1])
        led2.greenDutyCycle(color2[1])
        led3.greenDutyCycle(color3[1])
        led1.blueDutyCycle(color1[2])
        led2.blueDutyCycle(color2[2])
        led3.blueDutyCycle(color3[2])
        #Update the map with the new colors
        ledMap[led1]=color1
        ledMap[led2]=color2
        ledMap[led3]=color3
        #delay
        time.sleep(.05)
    led1.stopPWM()
    led2.stopPWM()
    led3.stopPWM()
    led1.cleanUp()
示例#4
0
def main():
    led = RGBLED()
    led.startPWM(100, 0)
    for i in range(0, 100):
        led.redDutyCycle(random.randint(0, 100))
        led.greenDutyCycle(random.randint(0, 100))
        led.blueDutyCycle(random.randint(0, 100))
        time.sleep(0.15)
    led.stopPWM()
    led.cleanUp()