Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. // NeoPixel Ring simple sketch (c) 2013 Shae Erisson
  2. // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
  3.  
  4. #include <Adafruit_NeoPixel.h>
  5. #ifdef __AVR__
  6. #include <avr/power.h>
  7. #endif
  8.  
  9. // Which pin on the Arduino is connected to the NeoPixels?
  10. // On a Trinket or Gemma we suggest changing this to 1
  11. #define PIN 1
  12.  
  13. // How many NeoPixels are attached to the Arduino?
  14. #define NUMPIXELS 16
  15.  
  16. // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
  17. // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
  18. // example for more information on possible values.
  19. Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
  20.  
  21. int delayval = 500; // delay for half a second
  22. int red = 0;
  23. int green = 0;
  24. int blue = 0;
  25. int ledMatrix[16][3];
  26. int firstColor[1][3]={150,0,0};
  27.  
  28. void setup() {
  29. // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  30. #if defined (__AVR_ATtiny85__)
  31. if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  32. #endif
  33. // End of trinket special code
  34.  
  35. strip.begin(); // This initializes the NeoPixel library.
  36.  
  37. }
  38.  
  39. void loop() {
  40.  
  41. // For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
  42.  
  43. int start=1000;
  44. if (millis()<=start+(delayval*NUMPIXELS)){
  45. for (int a=0;a<NUMPIXELS;a++){
  46. if (a>((millis()-start)/delayval)){
  47. red = firstColor[0][0];
  48. green = firstColor[0][1];
  49. blue = firstColor[0][2];
  50. ledMatrix[a][0]= firstColor[0][0];
  51. ledMatrix[a][1]= firstColor[0][1];
  52. ledMatrix[a][2]= firstColor[0][2];
  53. }
  54. //else tylko dla płynnego uruchamiania
  55. else if (a=((millis()-start)/delayval)){
  56. int factor = ((millis()-start)%delayval)/delayval;
  57. ledMatrix[a][0]= firstColor[0][0]*factor;
  58. ledMatrix[a][1]= firstColor[0][1]*factor;
  59. ledMatrix[a][2]= firstColor[0][2]*factor;
  60. }
  61.  
  62. }
  63. for (int a=0;a<NUMPIXELS;a++)
  64. {
  65. strip.setPixelColor(a,ledMatrix[a][0],ledMatrix[a][1],ledMatrix[a][2]);
  66. }
  67. strip.show();
  68.  
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement