Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define NUM_LEDS_IN_SEGMENT 2
- #define NUM_SIDES 4
- #define NUM_LEDS 12
- #define DATA_PIN 3
- #define CLOCK_PIN 13
- #define BRIGHTNESS 255
- struct CRGB leds[NUM_LEDS_IN_SEGMENT * NUM_SIDES];
- int sideLeds[NUM_LEDS_IN_SEGMENT * NUM_SIDES];
- int sideState[6][4] = {
- {4, 6, 2, 5}, // 1 0,1
- {5, 1, 6, 3}, // 2 2,3
- {5, 2, 6, 4}, // 3 4,5
- {3, 6, 1, 5}, // 4 6,7
- {4, 1, 2, 3}, // 5 8,9
- {3, 2, 1, 4} // 6 10,11
- };
- int state = 1;
- int pos = 0;
- void setup() {
- // put your setup code here, to run once:
- Serial.begin(9600); // start serial for output
- FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, BRG>(leds, NUM_LEDS);
- FastLED.clear();
- FastLED.setBrightness(BRIGHTNESS);
- }
- void loop() {
- Serial.print(" State: "); Serial.print(state); Serial.print(" || ");
- for (int i = 0; i < NUM_SIDES; i++) {
- for (int j = 0; j < NUM_LEDS_IN_SEGMENT; j++) {
- sideLeds[i] = (sideState[state - 1][i] * NUM_LEDS_IN_SEGMENT) - NUM_LEDS_IN_SEGMENT;
- sideLeds[i] += j;
- Serial.print(sideLeds[i]);Serial.print(" ");
- leds[sideLeds[i]] = CRGB::Red;
- FastLED.show();
- }
- }
- delay(500);
- for (int i = 0; i < NUM_LEDS; i++) {
- // int pos = sideLeds[i];
- leds[i] = CRGB( 0, 0, 0 );
- }
- FastLED.show();
- delay(250);
- Serial.println();
- state++;
- if (state > 6) state = 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement