bk227865

Untitled

Nov 17th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. #include <FastLED.h>
  2. //#include <string.h>
  3.  
  4. #define DATA_PIN 5
  5. #define CLOCK_PIN 6
  6. #define COLOR_ORDER GRB
  7. #define CHIPSET WS2812
  8. #define NUM_LEDS 453
  9.  
  10. #define BRIGHTNESS 40
  11.  
  12. CRGB leds[NUM_LEDS];
  13.  
  14. unsigned long Timer;
  15.  
  16. void setup() {
  17. delay(3000); // sanity delay
  18. FastLED.addLeds<CHIPSET, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  19. FastLED.setBrightness( BRIGHTNESS );
  20. FastLED.setCorrection( CRGB( 255, 230, 240) );
  21. Timer=millis();
  22. }
  23.  
  24. void loop() {
  25. if (millis()-Timer>=15) { //15*70=1050 so a pause of 15 millis results in 70 Frames per second aprroximatly
  26. Timer=millis();
  27. drawrings();
  28. FastLED.show();
  29. }
  30. }
  31.  
  32.  
  33. void drawrings()
  34.  
  35. {
  36.  
  37.  
  38. static byte framecounter;
  39.  
  40.  
  41. int lp1=0; //startposition ring 1
  42. int lp2=80; //startposition ring 2
  43. int lp3=151; //startposition ring 3
  44. int lp4=215; //startposition ring 4
  45. int lp5=271; //startposition ring 5
  46. int lp6=318; //startposition ring 6
  47. int lp7=357; //startposition ring 7
  48. int lp8=388; //startposition ring 8
  49. int lp9=411; //startposition ring 9
  50. int lp10=427; //startposition ring 10
  51.  
  52.  
  53. int lg1=80; //size of ring 1
  54. int lg2=71; //size of ring 2
  55. int lg3=64; //size of ring 3
  56. int lg4=56; //size of ring 4
  57. int lg5=47; //size of ring 5
  58. int lg6=39; //size of ring 6
  59. int lg7=31; //size of ring 7
  60. int lg8=23; //size of ring 8
  61. int lg9=16; //size of ring 9
  62. int lg10=8; //size of ring 10
  63.  
  64.  
  65. int cw;
  66. int cwv;
  67. byte z;
  68.  
  69. framecounter=framecounter+2;
  70.  
  71.  
  72. for(z=0; z<lg1; z++) { //draw ring 1
  73. cw=cubicwave8(z*1024/lg1+framecounter);
  74. cwv=cw*cw*cw/65536;
  75. leds[z+lp1]=CRGB(cwv,255-cwv,0);
  76. }
  77.  
  78. for(z=0; z<lg2; z++ ) { //draw ring 2
  79. cw=cubicwave8(z*1024/lg2+framecounter+20);
  80. cwv=cw*cw*cw/65536;
  81. leds[z+lp2]=CRGB(cwv,255-cwv,0);
  82. }
  83.  
  84. for(z=0; z<lg3; z++ ) { //draw ring 3
  85. cw=cubicwave8(z*1024/lg3+framecounter+40);
  86. cwv=cw*cw*cw/65536;
  87. leds[z+lp3]=CRGB(cwv,255-cwv,0);
  88. }
  89.  
  90. for(z=0; z<lg4; z++ ) { //draw ring 4
  91. cw=cubicwave8(z*1024/lg4+framecounter+60);
  92. cwv=cw*cw*cw/65536;
  93. leds[z+lp4]=CRGB(cwv,255-cwv,0);
  94. }
  95.  
  96. for(z=0; z<lg5; z++ ) { //draw ring 5
  97. cw=cubicwave8(z*1024/lg5+framecounter+80);
  98. cwv=cw*cw*cw/65536;
  99. leds[z+lp5]=CRGB(cwv,255-cwv,0);
  100. }
  101.  
  102. for(z=0; z<lg6; z++ ) { //draw ring 6
  103. cw=cubicwave8(z*1024/lg6+framecounter+100);
  104. cwv=cw*cw*cw/65536;
  105. leds[z+lp6]=CRGB(cwv,255-cwv,0);
  106. }
  107.  
  108. for(z=0; z<lg7; z++ ) { //draw ring 7
  109. cw=cubicwave8(z*1024/lg7+framecounter+120);
  110. cwv=cw*cw*cw/65536;
  111. leds[z+lp7]=CRGB(cwv,255-cwv,0);
  112. }
  113.  
  114. for(z=0; z<lg8; z++ ) { //draw ring 8
  115. cw=cubicwave8(z*1024/lg8+framecounter+140);
  116. cwv=cw*cw*cw/65536;
  117. leds[z+lp8]=CRGB(cwv,255-cwv,0);
  118. }
  119.  
  120. for(z=0; z<lg9; z++ ) { //draw ring 9
  121. cw=cubicwave8(z*1024/lg9+framecounter+160);
  122. cwv=cw*cw/256;
  123. leds[z+lp9]=CRGB(cwv,255-cwv,0);
  124. }
  125.  
  126. for(z=0; z<lg10-3; z++ ) { //draw ring 10
  127. cw=cubicwave8(z*1024/lg10+framecounter+180);
  128. cwv=cw*cw/256;
  129. leds[z+lp10]=CRGB(cwv,255-cwv,0);
  130. }
  131.  
  132. for (byte x=1;x<6;x=x+1) { //draw star
  133. leds[432+x]=CRGB(255-x*30,255-x*45,0);
  134. }
  135. leds[432]=CRGB(255,255,200);
  136.  
  137. }
Advertisement
Add Comment
Please, Sign In to add comment