Created
April 7, 2016 08:56
-
-
Save VessoVit/d2bd71bfbb90329b214a0943a82f123f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Adafruit_NeoPixel.h> | |
#define PIN 6 | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(20, PIN, NEO_GRB + NEO_KHZ800); | |
int fadeControl = 255;//will hold the current brightness level | |
int fadeDirection = -1;//change sigen to fade up or down | |
void setup() { | |
strip.begin(); | |
strip.show(); | |
} | |
void loop() { | |
bluepulse(150); | |
} | |
void bluepulse(uint8_t fadeStep) { | |
uint16_t i, j; | |
for(j=0; j<256; j++) { | |
for(i=0; i<20; i++) { | |
strip.setPixelColor(i, 0, 0, Wheel((i+j))); | |
//strip.setPixelColor(i, (0, 0, 127)); //Blue Color pixels | |
strip.setBrightness(fadeControl);//set the strip brightness | |
fadeControl = fadeControl + fadeDirection;//increment the brightness value | |
if (fadeControl <20 || fadeControl > 255) | |
//If the brightness value has gone past its limits... | |
{ | |
fadeDirection = fadeDirection * -1;//change the direction... | |
fadeControl = fadeControl + fadeDirection;//...and start back. | |
} | |
} | |
strip.show(); | |
delay(fadeStep);//wait a bit before doing it again. | |
} | |
} | |
uint32_t Wheel(byte WheelPos) { | |
if(WheelPos < 85) { | |
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0); | |
} else if(WheelPos < 170) { | |
WheelPos -= 85; | |
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3); | |
} else { | |
WheelPos -= 170; | |
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment