Here's my code:
[code]
import time, machine, neopixel, math
number_of_leds = 60
np = neopixel.NeoPixel(machine.Pin(5), number_of_leds)
def main():
while True:
fade_in_out(red_val=256, green_val=256, blue_val=256) # white
def fade_in_out(red_val, green_val, blue_val):
for i in range(256):
r = math.ceil((i/256)*red_val)
g = math.ceil((i/256)*green_val)
b = math.ceil((i/256)*blue_val)
for pixel_num in range(0, number_of_leds):
np[pixel_num] = (r, g, b)
np.write()[/code]
The animation starts at well, but ends fading into a yellow. Here is a (sped up) gif of what it looks like: http://imgur.com/a/t1CWX
Any help/code suggestions would be greatly appreciated! Thanks.
edit: Sorry for the lack of code editing... couldn't get it to work right.
What is making my LED's go yellow?
What is making my LED's go yellow?
Last edited by gregsvo on Wed Nov 16, 2016 1:49 pm, edited 2 times in total.
Re: What is making my LED's go yellow?
What makes me suspicious, is the 256.
You have 8 bits per color which is a number between 0 and 255, in total 256 values.
That is the maximum brightness level you can get is 255,255,255 and not 256,256,256
Maybe that solves already the problem
You have 8 bits per color which is a number between 0 and 255, in total 256 values.
That is the maximum brightness level you can get is 255,255,255 and not 256,256,256
Maybe that solves already the problem
Re: What is making my LED's go yellow?
I don't think that is the problem as whilst you are right about the 256 and 255 issue, his actual code will work out to 255 anyway as the maximum of range(256) is 255 and math.ceil(255/256*256) is 255.
I would guess that it is some sort of timing issue with the data transfer.
I would guess that it is some sort of timing issue with the data transfer.
Re: What is making my LED's go yellow?
Can you speak more about this? I'm not sure where to start. The LED's go yellow on different codes as well, for example:Neil wrote:...I would guess that it is some sort of timing issue with the data transfer.
Code: Select all
import time, machine, neopixel
number_of_leds = 60
np = neopixel.NeoPixel(machine.Pin(5), number_of_leds)
def main():
while True:
strobe(red_val=0xff, green_val=0xff, blue_val=0xff, strobe_count=10, flash_delay=50, end_pause=1000)
def strobe(red_val, green_val, blue_val, strobe_count, flash_delay, end_pause):
for _ in range(0, strobe_count):
set_all(red_val=red_val, green_val=green_val, blue_val=blue_val)
show_strip()
time.sleep_ms(flash_delay)
set_all(0, 0, 0)
show_strip()
time.sleep_ms(flash_delay)
time.sleep_ms(end_pause)
def show_strip():
np.write()
def set_pixel(pixel_num, red_val, green_val, blue_val):
np[pixel_num] = (red_val, green_val, blue_val)
def set_all(red_val, green_val, blue_val):
for i in range(0, number_of_leds):
set_pixel(pixel_num=i, red_val=red_val, green_val=green_val, blue_val=blue_val)
show_strip()
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: What is making my LED's go yellow?
I've not followed this in detail but there has been recent work on Github to address Neopixel timing issues. Have you updated the firmware?
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: What is making my LED's go yellow?
I think this was the github issue: https://github.com/micropython/micropython/pull/2532 with the original report being https://github.com/micropython/micropython/issues/2465
Re: What is making my LED's go yellow?
I haven't updated to 1.8.6 yet, but will give it a try today, and report back. Thanks!
Re: What is making my LED's go yellow?
THANK YOU Pythoncoder and Platforma!
The update to 1.8.6 fixed the issue.
The update to 1.8.6 fixed the issue.