#include #ifdef __AVR__ #include // Required for 16 MHz Adafruit Trinket #endif #define LED_PIN 2 #define LED_COUNT 39 Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); int k; int val; void setup() { Serial.begin(9600); #if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) clock_prescale_set(clock_div_1); #endif strip.begin(); // INITIALIZE NeoPixel strip object strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255) } void loop() { if (Serial.available()) { val = Serial.read(); if (val == 'r') // red color { colorWipe(strip.Color(255, 0, 0), 50); } if (val == 'g') // green color { colorWipe(strip.Color(0, 255, 0), 50); } if (val == 'b') // blue color { colorWipe(strip.Color(0, 0, 255), 50); } if (val == 'w') // white color { colorWipe(strip.Color(255, 255, 255), 50); } if (val == 'y') //yellow color { colorWipe(strip.Color(255, 255, 0), 50); } if (val == 'm') //magenta color { colorWipe(strip.Color(255, 0, 255), 50); } if (val == 'c') //cyan color { colorWipe(strip.Color(0, 255, 255), 50); } if (val == 'R') //Rainbow color { rainbow(10); } if (val == 'o') //off NeoPixel { colorWipe(strip.Color(0, 0, 0), 50); } } } void rainbow(int wait) { //1 for(long firstPixelHue = 0; firstPixelHue < 5*65536; firstPixelHue += 256) { for(int i=0; i