Neopixel spectrum of colors

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
efc
 
Posts: 16
Joined: Sat Nov 20, 2021 11:00 am

Neopixel spectrum of colors

Post by efc »

I am writing NeoPixel code with CircuitPython, and it seems that NeoPixels are quite limited in the spectrum of colors they can produce. With CircuitPython I can only get a NeoPixel to turn on (any value greater than 127) or turn off (any value less than 128). In other words (255, 0, 255) will look exactly the same as (255, 100, 130).

Is this the way NeoPixels are supposed to behave? I can’t find any documentation on the actual spectrum of colors they should be able to produce, though I find lots of example code that implies that the two colors above should display as distinct colors on a NeoPixel. Can anyone confirm this one way or another.

If NeoPixels should be able to display full RGB spectrum, does anyone have any idea what I may be doing wrong in CircuitPython?

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Neopixel spectrum of colors

Post by dastels »

What is the brightness set to?
Can you post your code?

NeoPixels use 8 bits for each of the three LEDs so they can create 255*255*255 = ~16.5 million colours. In theory anyway. The human eye can't distinguish nearly that fine of distinctions. Plus there's effects of the plastic the light travels through on its way out of the pixel.

You should be able to see plenty of different colors, though.

Dave

User avatar
efc
 
Posts: 16
Joined: Sat Nov 20, 2021 11:00 am

Re: Neopixel spectrum of colors

Post by efc »

Dave, I took a closer look and found that I am able to distinguish the colors. Here is the code I am using for a test...

Code: Select all

import time
import board
import neopixel

strip = neopixel.NeoPixel(board.A1, 8, brightness=0.1, pixel_order=neopixel.GRBW)
strip.fill((0,0,0, 0))

while True:
    strip[0] = (255,0,255, 0)
    strip[1] = (255,0,255, 0)
    strip[6] = (255,100,130, 0)
    strip[7] = (255,100,130, 0)
    time.sleep(5)
    strip[0] = (255,0,0, 0)
    strip[1] = (255,0,0, 0)
    strip[6] = (255,100,120, 0)
    strip[7] = (255,100,120, 0)
    time.sleep(5)
    strip[0] = (0,0,255, 0)
    strip[1] = (0,0,255, 0)
    strip[6] = (100,100,255, 0)
    strip[7] = (100,100,255, 0)
    time.sleep(5)
Using this I can see the difference between the 0/1 pixels on one end and the 6/7 pixels on the other. So the full spectrum is working just fine! I'm not sure why I couldn't see it last night, but all is well.

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Neopixel spectrum of colors

Post by dastels »

OK, your brightness is really low. Here's what's happening.
Each LED (the 4 of them: R, G, B, and W) can be set to a strength of 0-255, also the code can set it to 0-255. The brightness you have set converts the latter to the formar.
With your brightness set to 0.1 all your LED values are divided by 10.
So when you set, say red, to 255, the LED is being set to 25. In fact all the LEDs will end up with values between 0 and 25. So that 25*25*25 ~= 15.5K colours... all of them fairly dim.
Another way to look at it is that 1 will end up in the LED the same as 24 100 will be the same as 124, etc. Your ability to make fine changes is lost.

Personally, I always have the brightness set to 100% (1.0) and manage the brightness with the colours values (0-255) I use. The drawback of that is that NeoPixels are really rather bright. However, you can pick the range of values you want to use, staying away from higher ones. The color you get from the pixel is set by the relationship between the 3 (again, ignoring white).

Dave

User avatar
efc
 
Posts: 16
Joined: Sat Nov 20, 2021 11:00 am

Re: Neopixel spectrum of colors

Post by efc »

Thanks again, Dave. That is a really helpful explanation. I think last night I had the brightness even lower (0.02) to protect my eyes in the dark!

User avatar
dastels
 
Posts: 15608
Joined: Tue Oct 20, 2015 3:22 pm

Re: Neopixel spectrum of colors

Post by dastels »

Yes, that would map 0-255 to 1-5! That would give you 216 possible colors.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”