#include "FastLED.h" // FastLED library. #if FASTLED_VERSION < 3001000 #error "Requires FastLED 3.1 or later; check github for latest code." #endif //This is where we adjust things to match our unique project: #define NUM_STRIPS 3 #define NUM_LEDS_PER_STRIP 16 #define NUM_LEDS NUM_LEDS_PER_STRIP * NUM_STRIPS #define BRIGHTNESS 255 // 255 is full brightness, 128 is half #define SATURATION 255 // 0-255, 0 is pure white, 255 is fully saturated color #define BUTTON_PIN 2 // Connect the button to GND and one of the pins. #define UPDATES_PER_SECOND 100 byte prevKeyState = HIGH; // button is active low static uint8_t middleIndex = NUM_LEDS_PER_STRIP; static uint8_t lastIndex = NUM_LEDS_PER_STRIP*2; int db[] = {5,4,3,2,1,0,15,14,13,12,11,10,9,8,7,6, 21,20,19,18,17,16,31,30,29,28,27,26,25,24,23,22, 33,32,47,46,45,44,43,42,41,40,39,38,37,36,35,34}; CRGB leds[NUM_LEDS]; //------------------SETUP------------------ void setup() { delay( 2000 ); // power-up safety delay // Assign pin 3, 5 and 6 as LED singal pin FastLED.addLeds(leds, 0, NUM_LEDS_PER_STRIP); FastLED.addLeds(leds, NUM_LEDS_PER_STRIP, NUM_LEDS_PER_STRIP); FastLED.addLeds(leds, NUM_LEDS_PER_STRIP*2, NUM_LEDS_PER_STRIP); FastLED.setBrightness( BRIGHTNESS ); pinMode(BUTTON_PIN, INPUT_PULLUP); } void loop() { byte currKeyState = digitalRead(BUTTON_PIN); if ((prevKeyState == LOW) && (currKeyState == HIGH)) { shortKeyPress(); } prevKeyState = currKeyState; secondhand(); fill_black(); middlehand(); middleIndex = middleIndex + 1; if (middleIndex == NUM_LEDS_PER_STRIP*2){ middleIndex = NUM_LEDS_PER_STRIP; fill_black2(); lasthand(); lastIndex = lastIndex + 1; if (lastIndex == NUM_LEDS_PER_STRIP*3){ lastIndex = NUM_LEDS_PER_STRIP*2; fill_black3(); } } } void shortKeyPress() { middleIndex = NUM_LEDS_PER_STRIP; lastIndex = NUM_LEDS_PER_STRIP*2; fill_black(); fill_black2(); fill_black3(); } void secondhand() { for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) { leds[db[i]] = CRGB::Red; FastLED.delay(100); } } void middlehand() { leds[db[middleIndex]] = CRGB::Green; FastLED.delay(100); } void lasthand() { leds[db[lastIndex]] = CRGB::Blue; FastLED.delay(100); } void fill_black() { for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) { leds[i] = CRGB::Black; } } void fill_black2() { for(int i = NUM_LEDS_PER_STRIP; i < NUM_LEDS_PER_STRIP*2; i++) { leds[i] = CRGB::Black; } } void fill_black3() { for(int i = NUM_LEDS_PER_STRIP*2; i < NUM_LEDS_PER_STRIP*3; i++) { leds[i] = CRGB::Black; } }