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