Welcome to Etherpad! This pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents! Get involved with Etherpad at http://etherpad.org *// A basic everyday NeoPixel strip test program. * *// NEOPIXEL BEST PRACTICES for most reliable operation: *// - Add 1000 uF CAPACITOR between NeoPixel strip's + and - connections. *// - MINIMIZE WIRING LENGTH between microcontroller board and first pixel. *// - NeoPixel strip's DATA-IN should pass through a 300-500 OHM RESISTOR. *// - AVOID connecting NeoPixels on a LIVE CIRCUIT. If you must, ALWAYS *// connect GROUND (-) first, then +, then data. *// - When using a 3.3V microcontroller with a 5V-powered NeoPixel strip, *// a LOGIC-LEVEL CONVERTER on the data line is STRONGLY RECOMMENDED. *// (Skipping these may work OK on your workbench but can fail in the field) * *#include *#ifdef __AVR__ * #include // Required for 16 MHz Adafruit Trinket *#endif * *// Which pin on the Arduino is connected to the NeoPixels? *// On a Trinket or Gemma we suggest changing this to 1: *#define LED_PIN D3 * *// How many NeoPixels are attached to the Arduino? *#define LED_COUNT 60 * *// Declare our NeoPixel strip object: *Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); *// Argument 1 = Number of pixels in NeoPixel strip *// Argument 2 = Arduino pin number (most are valid) *// Argument 3 = Pixel type flags, add together as needed: *// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs) *// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers) *// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products) *// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2) *// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products) * * *// setup() function -- runs once at startup -------------------------------- * *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): * pinMode(buttonPin, INPUT); *#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000) * clock_prescale_set(clock_div_1); *#endif * // END of Trinket-specific code. * * strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED) * strip.show(); // Turn OFF all pixels ASAP * strip.setBrightness(199); // Set BRIGHTNESS to about 0/5 (max = 255) *} * * *// loop() function -- runs repeatedly as long as board is on --------------- * *void loop() { * buttonState = digitalRead(buttonPin); * if (buttonState == HIGH) { * // Fill along the length of the strip in various colors... * colorWipe(strip.Color( 255, 0, 0), 1); // Red * colorWipe(strip.Color( 0, 255, 0), 1); // Green * colorWipe(strip.Color( 0, 0, 255), 1); // Blue * * // Do a theater marquee effect in various colors... * theaterChase(strip.Color( 0x65, 0x98, 0x76), 1); // White, half brightness * theaterChase(strip.Color(255, 0, 0), 1); // Red, half brightness * theaterChase(strip.Color( 0, 255, 0), 1); // Blue, half brightness * * //rainbow(10); // Flowing rainbow cycle along the whole strip * //theaterChaseRainbow(50); // Rainbow-enhanced theaterChase variant * } *} * * *// Some functions of our own for creating animated effects ----------------- * *// 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 RGB * strip.setPixelColor(c, color); // Set pixel 'c' to value 'color' * } * strip.show(); // Update strip with new contents * delay(wait); // Pause for a moment * firstPixelHue += 65536 / 90; // One cycle of color wheel over 90 frames * } * } *}