/ PyLeap_Button_Half_NeoPixel_Control / code.py
code.py
1 # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 """Circuit Playground Bluefruit NeoPixel Button Control 6 7 Press button A to light up half the NeoPixels and button B to light up the other half. 8 """ 9 from adafruit_circuitplayground import cp 10 11 # Choose colors. Defaults to red for button A and green for button B. These are RGB values, where 12 # (r, g, b) represents red, green, and blue. Each value has a range of 0-255, where 0 is off and 13 # 255 is max intensity. You can update these values to change the colors. For example, (0, 255, 0) 14 # would be max green. You can combine numbers within the range to make other colors such as 15 # (255, 0, 180) being pink. Try it out! 16 color_value_a = (255, 0, 0) 17 color_value_b = (0, 255, 0) 18 19 cp.pixels.brightness = 0.3 20 21 while True: 22 if cp.button_a: 23 cp.pixels[0:5] = [color_value_a] * 5 24 else: 25 cp.pixels[0:5] = [(0, 0, 0)] * 5 26 27 if cp.button_b: 28 cp.pixels[5:10] = [color_value_b] * 5 29 else: 30 cp.pixels[5:10] = [(0, 0, 0)] * 5