Python code causes faded neopixel colors where it should be bright

215 Views Asked by At

I'm using a microbit connected to a neopixel with 32(8x4) lights, and in the code I've made, where I've specified the code to be blue(or any color), the result is a very weak and faded color

from microbit import *
import time
import neopixel
o=20
RED = (255, 0, 0)
YELLOW = (255, 150, 0)
GREEN = (0, 255, 0)
CYAN = (0, 255, 255)
BLUE = (0, 0, 255)
PURPLE = (180, 0, 255)
WHITE = (255,255,255)
BLACK= (0,0,0)
pixels = neopixel.NeoPixel(pin0, 32)
left=[0,8,16,24]
right=[7,15,23,31]
up=[0,1,2,3,4,5,6,7]
down=[24,25,26,27,28,29,30,31]
while True:
    if accelerometer.is_gesture("up"):
        if o not in up:
            o -= 8
    elif accelerometer.is_gesture("down"):
        if o not in down:
            o += 8
    elif accelerometer.is_gesture("left"):
        if o not in left:
            o -= 1
    elif accelerometer.is_gesture("right"):
        if o not in right:
            o+=1
    for i in range(32):
        if i != o:
            pixels[i] = RED
    pixels[o] = BLUE
    pixels.show()
    time.sleep(0.1)

Even though I've specified a bright blue(0,0,255), I get a result that is only a tiny flicker of blue, compared to the full blue I get when I run it without a background color. All of the reds are fine and bright too, so I don't really understand why the blue comes out so weak. When I change the background color from red to black, the blue is the right brightness, but when I try any other strong color, it fades again.

0

There are 0 best solutions below