Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float brightness = 1.0;
- uint32_t strip_state=0;
- uint32_t Wheel(Adafruit_NeoPixel *strip, byte WheelPos) {
- WheelPos = 255 - WheelPos;
- if(WheelPos < 85) {
- return strip->Color((255 - WheelPos * 3)*brightness, 0, WheelPos * 3*brightness);
- }
- if(WheelPos < 170) {
- WheelPos -= 85;
- return strip->Color(0, WheelPos * 3 * brightness, (255 - WheelPos * 3)*brightness);
- }
- WheelPos -= 170;
- return strip->Color(WheelPos * 3 * brightness, (255 - WheelPos * 3)*brightness, 0);
- }
- void fill_color(uint32_t color){
- byte r= ((color & 0xFF0000) >> 16) * brightness;
- byte g= ((color & 0xFF00) >> 8) *brightness;
- byte b= (color & 0xFF) * brightness;
- color = strip.Color(r,g,b);
- for(unsigned int i=0; i < strip.numPixels(); i++) {
- strip.setPixelColor(i, color);
- }
- strip.show();
- }
- void fade_color(){
- for(unsigned int i=0;i<strip.numPixels();i++){
- strip.setPixelColor(i,Wheel(&strip,strip_state));
- }
- strip.show();
- strip_state++;
- if(strip_state>255) strip_state = 0;
- }
- void moving_rainbow(){
- for(unsigned int i=0; i<strip.numPixels(); i++) {
- strip.setPixelColor(i, Wheel(&strip,((i * 256 / strip.numPixels()) + strip_state) & 255));
- }
- strip.show();
- strip_state++;
- }
- void colorWipe(uint32_t color) {
- byte r= ((color & 0xFF0000) >> 16) * brightness;
- byte g= ((color & 0xFF00) >> 8) *brightness;
- byte b= (color & 0xFF) * brightness;
- color = strip.Color(r,g,b);
- strip.setPixelColor(strip_state, color);
- strip.show();
- strip_state++;
- }
- //Theatre-style crawling lights.
- void theaterChase(uint32_t c) {
- byte r= ((c & 0xFF0000) >> 16) * brightness;
- byte g= ((c & 0xFF00) >> 8) *brightness;
- byte b= (c & 0xFF) * brightness;
- c = strip.Color(r,g,b);
- for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
- strip.setPixelColor(i + strip_state % 3, c); //turn every third pixel on
- strip.setPixelColor(i + (strip_state +1) % 3, 0); // turn others off
- strip.setPixelColor(i + (strip_state +2) % 3, 0);
- }
- strip.show();
- strip_state++;
- }
- //Theatre-style crawling lights with rainbow effect
- void theaterChaseRainbow() {
- for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
- strip.setPixelColor(i + strip_state % 3, Wheel(&strip, (i+strip_state) % 255)); //turn every third pixel on
- strip.setPixelColor(i + (strip_state +1) % 3, 0); // turn others off
- strip.setPixelColor(i + (strip_state +2) % 3, 0);
- }
- strip.show();
- strip_state++;
- }
Add Comment
Please, Sign In to add comment