Hello friends, I am having problems implementing this code in Adafruit NeoPixel Shield for Arduino - 40 RGB LED Pixel Matrix, it runs normal for a few minutes and then crashes. Here is the code below:
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
#define LED_PIN 6
#define LED_COUNT 40
#define LED_BRIGHTNESS 5
Adafruit_NeoPixel strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
int t;
void setup() {
// These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
// Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
clock_prescale_set(clock_div_1);
#endif
// END of Trinket-specific code.
strip.begin();
strip.show();
strip.clear();
strip.setBrightness(LED_BRIGHTNESS);
}
void loop() {
t++;
for (int i = 0; i < LED_COUNT; i++) {
int cng = LED_COUNT / 2 + cos(i * 0.5 + t) * LED_COUNT / 2;
if (cng > LED_COUNT / 10) {
strip.setPixelColor(i, strip.Color(255, sin(t)*255, 0));
}
if (cng > LED_COUNT / 5) {
strip.setPixelColor(i, strip.Color(0, 255, 0));
}
if (cng > LED_COUNT / 2) {
strip.setPixelColor(i, strip.Color(0, 0, 255));
}
}
strip.show();
delay(50);
}