I am currently working on some code where I want to turn Neopixels on/off. I have them grouped so that I can iterate through an object and turn the group off/on all at once.
However, when I send serial commands to perform this action, I noticed that half of the group turns off and the other half become some strange color (Mostly blue). It does not matter what their starting color was, they become blue. And the other group, all becomes white (I have RGBW LEDs). This also happens when I try to change the groups brightness.
Right off the bat, does this issue sound familiar to anyone?
Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.
Please post a schematic.
Please post an image of your project.
Please describe the problem better then you just did.
I apologize for the delay. Things got really busy for awhile. Anyways, here is the logic I am implementing to light my leds. To explain what is happening, I have an object for various LED channels. In the channels, I can have 2 or 3 or more LEDS assigned. The object here lights a specific channel. Additionally, I can bridging between strips because the channels are independent of the LED strips (For ex, in 1 channel I can have 2 LEDs, the last led of a strip + the first LED of another strip)
The issue that I am seeing here is that when I change a channel's color or when I turn the channel on/off, the next channel on the strip changes to a random blue color. I am not sure what the issue could be. At first I am thinking that it could be the way that the data is being sent to the pixel color.
void SetRoomColor(ColorObject RoomColor, bool saveRoomColor = true)
{
LEDStrip *StripReference = m_StripArrayObjects[0];
ColorObject modifiedColor;
if(saveRoomColor)
m_RoomColor = RoomColor;
modifiedColor.SetColor( (uint8_t)(((uint16_t)m_brightness * (uint16_t)RoomColor.GetRedValue()) / 255),
(uint8_t)(((uint16_t)m_brightness * (uint16_t)RoomColor.GetGreenValue()) / 255),
(uint8_t)(((uint16_t)m_brightness * (uint16_t)RoomColor.GetBlueValue()) / 255),
RoomColor.GetWhiteValue());
uint8_t positionCounter = 0;
bool firstRunThroughComplete = false;
// First check if there is another strip associated with the room to display colors
for(uint16_t LEDNumber : m_LEDNumberArray)
{
//uint16_t finalNumber = LEDNumber - 1;
//StripReference->GetStripReference()->setPixelColor(finalNumber, 0, 0, 0, 0);
if(LEDNumber == 1 && firstRunThroughComplete)
{
positionCounter = LEDNumber;
break;
}
firstRunThroughComplete = true;// This should help with the case where the first element is 1.
}
uint8_t count = 0;
if(positionCounter == 0)
{
// If just a single strip, the logic to fill the LEDs is simple
count = m_LEDNumberArray.at(m_LEDNumberArray.size() - 1) - m_LEDNumberArray.at(0);
StripReference->GetStripReference()->fill(0, m_LEDNumberArray.at(0) - 1, count + 1);
StripReference->GetStripReference()->fill(modifiedColor.GetColorValue(), m_LEDNumberArray.at(0) - 1, count + 1);
StripReference->GetStripReference()->show();
}
else
{
for(uint16_t LEDNumber : m_LEDNumberArray)
{
if(LEDNumber == positionCounter)// This is here in the event that the room has 2 strips
{
// Turn on the strip that was previously being edited?
StripReference->GetStripReference()->show();
StripReference = m_StripArrayObjects[1];
}
uint16_t finalNumber = LEDNumber - 1;
StripReference->GetStripReference()->setPixelColor(finalNumber, 0, 0, 0, 0);
StripReference->GetStripReference()->setPixelColor(finalNumber, modifiedColor.GetColorValue());
}
StripReference->GetStripReference()->show();
}
}
Three requests for schematics, etc. have been ignored. We ask for this not to be pedantic, but to clarify conditions which may be assumed by you to be ok, but are not, and to gain understanding of what you're trying to accomplish.
Will you provide a schematic and an image of your project all wired up? The description of the issue reads like a power supply issue. Without the schematic...
And code snippets suck.
here is how I use an array pointer to do the thing.
void fProcessAirPressure ( void *pvParemeters )
{
int Ticks = 118; // Tick counter
bool Filled = false; // array has been filled before?
float *ptr = CollectionPressure; // pointer to the array
const int ticksTrigger = 120; // triggered at 1 minute intervals
for (;;)
{
//triggered by BME which is triggered by the 1 minute hardware timer.
xEventGroupWaitBits (eg, evtStoreAirPressure, pdTRUE, pdTRUE, portMAX_DELAY );
xSemaphoreTake( sema_CollectPressure, portMAX_DELAY );
xSemaphoreTake ( sema_eData, portMAX_DELAY );
if ( !Filled )
{
//if array has not been filled before, fill array with the same base value
for ( int j = 0; j < BufferCount; j++ )
{
*( ptr + j ) = x_eData.oPressure;
}
Filled = true;// array has been initially filled
} else {
if ( Ticks == ticksTrigger )
{
//when tick counter reaches the trigger level
//shift contents left and insert new value at the end
for ( int i = 0; i <= BufferCount - 2; i++ )
{
*( ptr + i ) = *( ptr + (i + 1) );
}
}
*( ptr + (BufferCount - 1) ) = x_eData.oPressure;//new value to be inserted
}
// find and store highest and lowest value
if ( x_eData.oPressure > x_eData.PressureH )
{
x_eData.PressureH = x_eData.oPressure;
}
if ( x_eData.oPressure < x_eData.PressureL )
{
x_eData.PressureL = x_eData.oPressure;
}
Ticks++;
if ( Ticks > ticksTrigger )
{
Ticks = 1;
}
//log_i( "ticks %d" , Ticks );
x_eData.cngPress = CalculatePressureFactors( *( ptr + 57), *( ptr + 59) ); // going back 4 hours
xSemaphoreGive( sema_eData );
xSemaphoreGive( sema_CollectPressure );
//
//log_i( " high watermark % d", uxTaskGetStackHighWaterMark( NULL ) );
} //for (;;)
vTaskDelete( NULL );
} //void fStoreAirPressure ( void *pvParemeters )
There are differences in the way I am using the array pointer and the way you are using it that may make a differences with success of use, I don't know.
I apologize. Here is a snippet of the schematic for the LED controller. This is for a client of mine and I am unable to post the entire schematic. I have multiple LED strips that are the same layout as posted
That's unfortunate. I don't chase ghosts, and playing 20 questions about your circuit is a waste of time. The problem may be entirely software, 'tis true, but I have my suspicions. Best of luck.
That is unfortunate to hear. The other components on the board are the ATMega Pro board and the Ethernet shield. I created a PCB for all of these to mount to. The data pins follow what is posted above with a bypass cap and the DataX pin going to the second pin of the terminal block. There is nothing really special about the schematic. I do not think that this is an issue related to the hardware.
Now I should note that I am powering this unit using the USB line. I have my suspicions that this could be causing an issue. I have connections for an external power supply if needed
NOW this comes to light? That is exactly why we press for schematics and details. Do a power analysis for the project. Just how much current are you sucking from the USB?
With 1 strip being lit at 5%, I am pulling 250 mA (I have a device that can measure USB current)
Truth be told, even if I gave you a schematic, it would not have known this as the USB port is on the dev board. The schematic does show the external power connection but does not show the USB power connection.
Tuning in late, but I must say that when you have suspicions, trust yourself and do something to test any hypotheses you have, sticking of course to things that won't do damages to your projext.
In this case just try it. Try using a good source of 5 volts or whatever the voltage is.