Skip to content

rain function does not show the eights columns #2

@MichaelJohannes

Description

@MichaelJohannes

I found following:
rain function does not show the eights column but why?
map function does not work like expected!
Want to map a value between 0 to 8 , tried set 9
in our case map(values[col], 0, 100, 0, 9) and it worked.
Here the corrected function:

void rain(int cycles, int delayTime) {
int rain[] = {0, 0, 0, 0, 0, 0, 0, 0};
for (int v = 0; v < 8; v++) {
rain[v] = random(0, 10) * 10;
}
for (int c = 0; c < cycles; c++) {
for (int f = 0; f < 10; f++) {
for (int col = 0; col < 8; col++) {
int row = map(rain[col], 0, 100, 0, 9); // map to 9 to reach 8 😃
if ((row % 2) == 1) {
pixels.setPixelColor((64 - row * 8) + (7 - col), pixels.Color(200, 200, 200));
} else {
pixels.setPixelColor((64 - row * 8) + col, pixels.Color(200, 200, 200));
}
}
pixels.show();
delay(delayTime);
for (int v = 0; v < 8; v++) {
rain[v] = (rain[v] + 10) % 100;
}
clear();
delay(100);
}
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions