Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <FastLED.h>
- #define NUM_LEDS 60
- #define LED_PIN 17
- CRGB leds[NUM_LEDS];
- #define BUTTON1_PIN 1
- #define BUTTON2_PIN 18
- #define BUTTON3_PIN 3
- #define BUTTON4_PIN 5
- #define BUTTON5_PIN 19
- unsigned long countdownTime = 0;
- unsigned long startTime = 0;
- void setup() {
- FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
- pinMode(BUTTON1_PIN, INPUT_PULLUP);
- pinMode(BUTTON2_PIN, INPUT_PULLUP);
- pinMode(BUTTON3_PIN, INPUT_PULLUP);
- pinMode(BUTTON4_PIN, INPUT_PULLUP);
- pinMode(BUTTON5_PIN, INPUT_PULLUP);
- }
- void loop() {
- if (millis() < 5000) {
- if (digitalRead(BUTTON1_PIN) == LOW) countdownTime += 3600;
- if (digitalRead(BUTTON2_PIN) == LOW) countdownTime += 600;
- if (digitalRead(BUTTON3_PIN) == LOW) countdownTime += 60;
- if (digitalRead(BUTTON4_PIN) == LOW) countdownTime += 10;
- if (digitalRead(BUTTON5_PIN) == LOW) countdownTime += 1;
- FastLED.showColor(CRGB::Green);
- } else {
- int ledToTurnOff = map(millis() - 5000, 0, countdownTime/60 * 1000 , 0, NUM_LEDS);
- for (int i = 0; i < NUM_LEDS; i++) {
- if (i < ledToTurnOff) {
- leds[i] = CRGB::Black;
- } else {
- leds[i] = CRGB::Red;
- }
- }
- FastLED.show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement