/* * Board: Arduino Mega 2560 * File: Lee_04 * Author: Clive "Max" Maxfield (max@clivemaxfield.com) * License: The MIT License (See full license at the bottom of this file) * * Notes: Simple test program to demo NeoPixels * Simple "breathing" effect */ #include // Library for NeoPixels #define pinPix 12 // Pin driving NeoPixel Ring or String #define numPix 16 // Number of NeoPixels in the Ring or Strip // Setup NeoPixel Ring // Parameter 1 = number of pixels in strip // Parameter 2 = pin number driving the strip // Parameter 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) Adafruit_NeoPixel myNeoPixels = Adafruit_NeoPixel(numPix, pinPix, NEO_GRB + NEO_KHZ800); void setup() { myNeoPixels.begin(); // Initialize the NeoPixel array in the Arduino's memory, myNeoPixels.show(); // turn all pixels off, and upload to ring or string } void loop() { letsDoIt(20, 20, 255,255,255); // Pause; Number of steps; Full-on R,G,B values } // Pause = delay between transitions // Steps = number of steps // R, G, B = Full-on RGB values void letsDoIt(int pause, int steps, byte R, byte G, byte B) { int tmpR, tmpG, tmpB; // Temp values // Fade up for (int s=1; s<=steps; s++) { tmpR = (R * s) / steps; // Multiply first to avoid truncation errors tmpG = (G * s) / steps; tmpB = (B * s) / steps; for (int i=0; i0; s--) { tmpR = (R * s) / steps; // Multiply first to avoid truncation errors tmpG = (G * s) / steps; tmpB = (B * s) / steps; for (int i=0; i