#include #ifdef __AVR__ #include // Required for 16 MHz Adafruit Trinket #endif #define LED_PIN 8 //LED control pin (ATtiny pin 5 (PB2) #define POT_PIN 2 //Potentiometer pin #define LED_COUNT 18 // How many NeoPixels are attached to the Arduino // NeoPixel brightness, 0 (min) to 255 (max) #define BRIGHTNESS 100 // Declare our NeoPixel strip object: Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800); void setup() { strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) strip.show(); // Turn OFF all pixels ASAP strip.setBrightness(BRIGHTNESS); // Set BRIGHTNESS (max = 255) pinMode (POT_PIN, INPUT); } void loop() { int brightn, pot_read; //int two variables for reading from the potentiometer and setting LED brightness pot_read = analogRead(POT_PIN); //reading from the potentiometer brightn = map(pot_read, 0, 1023, 0, 255); //maping potentiomete value from 0-1023 to 0-255 and reversing it so the max will be on the right //fill with white light if 'brightn' > 5 if (brightn > 5) { colorWipe(strip.Color(0, 0, 0, brightn), 0); // True white (not RGB white) delay (100); } else { colorWipe(strip.Color(0, 0, 0, 0), 0); // True white (not RGB white) } } // Fill strip pixels one after another with a color. Strip is NOT cleared // first; anything there will be covered pixel by pixel. Pass in color // (as a single 'packed' 32-bit value, which you can get by calling // strip.Color(red, green, blue) as shown in the loop() function above), // and a delay time (in milliseconds) between pixels. void colorWipe(uint32_t color, int wait) { for (int i = 0; i < strip.numPixels(); i++) { // For each pixel in strip... strip.setPixelColor(i, color); // Set pixel's color (in RAM) strip.show(); // Update strip to match delay(wait); // Pause for a moment } }