Simple test

Ensure your device works with this simple test.

examples/rgbled_simpletest.py
 1# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
 2# SPDX-License-Identifier: MIT
 3
 4import time
 5
 6import board
 7from rainbowio import colorwheel
 8
 9import adafruit_rgbled
10
11# Pin the Red LED is connected to
12RED_LED = board.D5
13
14# Pin the Green LED is connected to
15GREEN_LED = board.D6
16
17# Pin the Blue LED is connected to
18BLUE_LED = board.D7
19
20# Create the RGB LED object
21led = adafruit_rgbled.RGBLED(RED_LED, GREEN_LED, BLUE_LED)
22
23# Optionally, you can also create the RGB LED object with inverted PWM
24# led = adafruit_rgbled.RGBLED(RED_LED, GREEN_LED, BLUE_LED, invert_pwm=True)
25
26
27def rainbow_cycle(wait):
28    for i in range(255):
29        i = (i + 1) % 256
30        led.color = colorwheel(i)
31        time.sleep(wait)
32
33
34while True:
35    # setting RGB LED color to RGB Tuples (R, G, B)
36    led.color = (255, 0, 0)
37    time.sleep(1)
38
39    led.color = (0, 255, 0)
40    time.sleep(1)
41
42    led.color = (0, 0, 255)
43    time.sleep(1)
44
45    # setting RGB LED color to 24-bit integer values
46    led.color = 0xFF0000
47    time.sleep(1)
48
49    led.color = 0x00FF00
50    time.sleep(1)
51
52    led.color = 0x0000FF
53    time.sleep(1)
54
55    # rainbow cycle the RGB LED
56    rainbow_cycle(0.1)