Advertisement
KelvinMead

kube_v5_testing_arraysc

Apr 24th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include <FastLED.h>
  2.  
  3. #define NUM_LEDS_IN_SEGMENT 2
  4. #define NUM_SIDES 4
  5.  
  6. #define NUM_LEDS 12
  7. #define DATA_PIN 3
  8. #define CLOCK_PIN 13
  9. #define BRIGHTNESS 255
  10.  
  11. struct CRGB leds[NUM_LEDS_IN_SEGMENT * NUM_SIDES];
  12. int sideLeds[NUM_LEDS_IN_SEGMENT * NUM_SIDES];
  13.  
  14. int sideState[6][4] = {
  15. {4, 6, 2, 5}, // 1 0,1
  16. {5, 1, 6, 3}, // 2 2,3
  17. {5, 2, 6, 4}, // 3 4,5
  18. {3, 6, 1, 5}, // 4 6,7
  19. {4, 1, 2, 3}, // 5 8,9
  20. {3, 2, 1, 4} // 6 10,11
  21. };
  22.  
  23. int state = 1;
  24. int pos = 0;
  25.  
  26. void setup() {
  27. // put your setup code here, to run once:
  28. Serial.begin(9600); // start serial for output
  29. FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, BRG>(leds, NUM_LEDS);
  30. FastLED.clear();
  31. FastLED.setBrightness(BRIGHTNESS);
  32. }
  33.  
  34. void loop() {
  35. Serial.print(" State: "); Serial.print(state); Serial.print(" || ");
  36.  
  37. for (int i = 0; i < NUM_SIDES; i++) {
  38. for (int j = 0; j < NUM_LEDS_IN_SEGMENT; j++) {
  39. sideLeds[i] = (sideState[state - 1][i] * NUM_LEDS_IN_SEGMENT) - NUM_LEDS_IN_SEGMENT;
  40. sideLeds[i] += j;
  41. Serial.print(sideLeds[i]);Serial.print(" ");
  42. leds[sideLeds[i]] = CRGB::Red;
  43.  
  44. FastLED.show();
  45. }
  46. }
  47. delay(500);
  48.  
  49. for (int i = 0; i < NUM_LEDS; i++) {
  50. // int pos = sideLeds[i];
  51. leds[i] = CRGB( 0, 0, 0 );
  52. }
  53. FastLED.show();
  54. delay(250);
  55.  
  56. Serial.println();
  57.  
  58. state++;
  59. if (state > 6) state = 1;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement