0

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.

Leo Gortz
  • 1
  • 1
  • Hi, please note that color perception isn't a programming topic. As you say, `(0,0,255)` **looks** faded when BG is red, for black BG blue *appears* okay, so this question is really about perception, You might consider building your own LED array with BLUE LEDs having higher cd/lux if you really need it. – RinkyPinku Dec 28 '19 at 02:36
  • Maybe I chose my words badly by saying "looks" faded. What I meant was that it is objectively weaker than it should be so I was wondering if there was an error in the code of the while loop that may cause this. The problem isn't just that it "looks" faded against the red, it's that the result is that there is only a tiny flicker of blue, contrary to the (0,0,255) I have specified – Leo Gortz Dec 28 '19 at 10:56

0 Answers0