Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // NeoPixel Ring simple sketch (c) 2013 Shae Erisson
- // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
- #include <Adafruit_NeoPixel.h>
- #ifdef __AVR__
- #include <avr/power.h>
- #endif
- // Which pin on the Arduino is connected to the NeoPixels?
- // On a Trinket or Gemma we suggest changing this to 1
- #define PIN 1
- // How many NeoPixels are attached to the Arduino?
- #define NUMPIXELS 16
- // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
- // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
- // example for more information on possible values.
- Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
- int delayval = 500; // delay for half a second
- int red = 0;
- int green = 0;
- int blue = 0;
- int ledMatrix[16][3];
- int firstColor[1][3]={150,0,0};
- void setup() {
- // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
- #if defined (__AVR_ATtiny85__)
- if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
- #endif
- // End of trinket special code
- strip.begin(); // This initializes the NeoPixel library.
- }
- void loop() {
- // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
- int start=1000;
- if (millis()<=start+(delayval*NUMPIXELS)){
- for (int a=0;a<NUMPIXELS;a++){
- if (a>((millis()-start)/delayval)){
- red = firstColor[0][0];
- green = firstColor[0][1];
- blue = firstColor[0][2];
- ledMatrix[a][0]= firstColor[0][0];
- ledMatrix[a][1]= firstColor[0][1];
- ledMatrix[a][2]= firstColor[0][2];
- }
- //else tylko dla płynnego uruchamiania
- else if (a=((millis()-start)/delayval)){
- int factor = ((millis()-start)%delayval)/delayval;
- ledMatrix[a][0]= firstColor[0][0]*factor;
- ledMatrix[a][1]= firstColor[0][1]*factor;
- ledMatrix[a][2]= firstColor[0][2]*factor;
- }
- }
- for (int a=0;a<NUMPIXELS;a++)
- {
- strip.setPixelColor(a,ledMatrix[a][0],ledMatrix[a][1],ledMatrix[a][2]);
- }
- strip.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement