## What is making my LED's go yellow?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
gregsvo
Posts: 10
Joined: Fri Oct 21, 2016 6:12 pm

### What is making my LED's go yellow?

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:

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.
Last edited by gregsvo on Wed Nov 16, 2016 1:49 pm, edited 2 times in total.

torwag
Posts: 217
Joined: Fri Dec 13, 2013 9:25 am

### 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

Neil
Posts: 15
Joined: Tue Jul 14, 2015 8:51 pm

### 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.

gregsvo
Posts: 10
Joined: Fri Oct 21, 2016 6:12 pm

### Re: What is making my LED's go yellow?

Neil wrote:...I would guess that it is some sort of timing issue with the data transfer.
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:

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: 3871
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

platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

### Re: What is making my LED's go yellow?

gregsvo
Posts: 10
Joined: Fri Oct 21, 2016 6:12 pm

### 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!

gregsvo
Posts: 10
Joined: Fri Oct 21, 2016 6:12 pm

### Re: What is making my LED's go yellow?

THANK YOU Pythoncoder and Platforma!

The update to 1.8.6 fixed the issue.