if (j >= 16) {
leds[3 * 16 + 2 * (j - 16)].r = 0; // RED
leds[3 * 16 + 2 * (j - 16)].g = 0; // BLUE
leds[3 * 16 + 2 * (j - 16)].b = 255; // GREEN
leds[3 * 16 + 2 * (j - 16) + 1].r = 0; // RED
leds[3 * 16 + 2 * (j - 16) + 1].g = 0; // BLUE
leds[3 * 16 + 2 * (j - 16) + 1].b = 255; // GREEN
}
Do the math. What happens when j == 24?
Once you start writing to memory that you don't own, you (deservedly) get unpredictable results.