Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //==================================
- //Version ATTiny
- #include <Adafruit_NeoPixel.h>
- #define PIN 0
- #define NUM_LEDS 110
- Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
- void setup() {
- strip.begin();
- strip.show(); // Initialize all pixels to 'off'
- }
- void loop() {
- meteorRain(0xff,0xff,0xff,5, 60, false, 0);
- }
- void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) {
- setAll(0,0,0);
- for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
- for(int j=0; j<NUM_LEDS; j++) {
- if( (!meteorRandomDecay) || (random(10)>5) ) {
- fadeToBlack(j, meteorTrailDecay );
- }
- }
- for(int j = 0; j < meteorSize; j++) {
- if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
- setPixel(i-j, red, green, blue);
- }
- }
- showStrip();
- delay(SpeedDelay);
- }
- }
- void fadeToBlack(int ledNo, byte fadeValue) {
- #ifdef ADAFRUIT_NEOPIXEL_H
- uint32_t oldColor;
- uint8_t r, g, b;
- int value;
- oldColor = strip.getPixelColor(ledNo);
- r = (oldColor & 0x00ff0000UL) >> 16;
- g = (oldColor & 0x0000ff00UL) >> 8;
- b = (oldColor & 0x000000ffUL);
- r=(r<=10)? 0 : (int) r-(r*fadeValue/256);
- g=(g<=10)? 0 : (int) g-(g*fadeValue/256);
- b=(b<=10)? 0 : (int) b-(b*fadeValue/256);
- strip.setPixelColor(ledNo, r,g,b);
- #endif
- #ifndef ADAFRUIT_NEOPIXEL_H
- #endif
- }
- //===================================
- void showStrip() {
- #ifdef ADAFRUIT_NEOPIXEL_H
- strip.show();
- #endif
- #ifndef ADAFRUIT_NEOPIXEL_H
- #endif
- }
- void setPixel(int Pixel, byte red, byte green, byte blue) {
- #ifdef ADAFRUIT_NEOPIXEL_H
- strip.setPixelColor(Pixel, strip.Color(red, green, blue));
- #endif
- #ifndef ADAFRUIT_NEOPIXEL_H
- #endif
- }
- void setAll(byte red, byte green, byte blue) {
- for(int i = 0; i < NUM_LEDS; i++ ) {
- setPixel(i, red, green, blue);
- }
- showStrip();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement