NeoPixel can't set 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
chrismyers81
 
Posts: 15
Joined: Sat Mar 01, 2014 12:14 pm

NeoPixel can't set colors?

Post by chrismyers81 »

So, I've got a weird one going on. Here's my code, running on a Mega 2960:
http://susepaste.org/980cfbb9

I'm trying to set the color of my system status NeoPixel (https://www.adafruit.com/products/1312) based on what's going on with the system (or green if all is ok.) However, it's not acting the way that I think it should.

First of all, I have to set it up to use the 400KHz setup, rather than the 800KHz (otherwise, it stays off.)

Secondly, all I ever get is white, even if I have nothing set to use the white color, or if I comment out the setter code in the timer function (lines 291-293) and hard-code the loop() to set it to be some other color.

Thirdly, I can't set the brightness, it's either all or nothing.

I tried the _RGB and _GRB, but changing this didn't make a difference.

I had originally had the color setting within the meat of the sensor-reading code, but it wasn't acting right there. I thought that maybe it might be conflicting with my timers, since the NeoPixel code needs timers to run and my code disables timers at various times. But it didn't make any difference.

Am I doing something wrong here?

Thanks!

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: NeoPixel can't set colors?

Post by pburgess »

Try running the strandtest example from the NeoPixel library, just changing the pin number and leaving the rest as-is. Any change?

chrismyers81
 
Posts: 15
Joined: Sat Mar 01, 2014 12:14 pm

Re: NeoPixel can't set colors?

Post by chrismyers81 »

Yep, it works fine with that sketch :)

So, it looks like it's something going on with how it interacts with my environmental monitor sketch. I got to thinking that maybe it was related to trying to run the color setter through the timer function, so I broke it out into its own function instead: http://susepaste.org/e4e8e317 and it still doesn't work like it should :/

Some other things I've tried -

Hard-coding the color and pin, rather than using variables
Adding a serial logger output for the LED color value, which logs the correct value, but doesn't kick the LED on.
Adding a color setter up at the very top inside of loop() with hard-coded values, which doesn't turn the LED on.

It looks like anytime I try to use the 800KHz setting, it doesn't do anything, but using 400KHz always sets the LED to white. (However, the strandtest uses 800KHz, so I know the LED itself works with that setting.)

chrismyers81
 
Posts: 15
Joined: Sat Mar 01, 2014 12:14 pm

Re: NeoPixel can't set colors?

Post by chrismyers81 »

Was just checking to see if anyone had had a chance to check out my code and see if there was a reason why it might not be interacting well with the NeoPixel libraries?

chrismyers81
 
Posts: 15
Joined: Sat Mar 01, 2014 12:14 pm

Re: NeoPixel can't set colors?

Post by chrismyers81 »

I'm guessing that it has something to do with the fact that I'm using interrupts, but I'm not really sure, or how to address this properly if that is the case.

chrismyers81
 
Posts: 15
Joined: Sat Mar 01, 2014 12:14 pm

Re: NeoPixel can't set colors?

Post by chrismyers81 »

I ended up finding this library, which seems to work fine for my needs :) It's not as full-featured as the Adafruit one, but it does what I need it to :)

https://github.com/cpldcpu/light_ws2812

User avatar
chemdoc77
 
Posts: 148
Joined: Mon Jan 28, 2013 9:32 am

Re: NeoPixel can't set colors?

Post by chemdoc77 »

Hi chrismyers81:

Your problem is because the interrupts that are used by the switch case statement are turned off at times when using NeoPixel library.

As noted in the following forum post:

viewtopic.php?f=47&t=51313&p=259217&hil ... el#p259217

“the NeoPixel library has to shut off interrupts while issuing data…”

I have had the same problem with the case statement in some of my NeoPixel sketches.

Your NeoPixels remain white because the switch case variable does not change due to the fact the interrupt is not on during a change in the input variable. Watch the serial print of this variable and you will see that it is not changing.

This is something that I still need to go back and solve, too.

Best Regards,
Chemdoc77

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

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