Skip to content

First LED in first loop gets bad value #7

Description

@alager

count is set to 1
old_val is stored at index count which is 1
Then in the next loop, x is assigned to count which is 1
finally old_val[x-1] which is index 0 has a value stored in it.
This creates a bad value for the first led, and it typically flashes white.

for (int count = 1; count<NUM_PIXELS; count++) {
strip.setPixelColor(count, color);
old_val[count] = color;
for(int x = count; x>0; x--) {
old_val[x-1] = dimColor(old_val[x-1], width);
strip.setPixelColor(x-1, old_val[x-1]);
}

*** The FIX ***
start the count loop at 0 and decrement the comparison to NUM_PIXELS by 1.
for (uint16_t count = 0; count < NUM_PIXELS-1; count++)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions