Created
August 22, 2019 22:31
-
-
Save tancredi/2dcf4a7369495ad5957a96dd821d6d7f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <HSBColor.h> | |
#include <Adafruit_NeoPixel.h> | |
#define BUTTON_PIN 3 | |
#define MODES_COUNT 7 | |
#define LED_PIN 6 | |
#define LED_COUNT 4 | |
int mode = 0; | |
bool modeButtonPressed = false; | |
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800); | |
void setup() { | |
Serial.begin(9600); | |
pinMode(BUTTON_PIN, INPUT); | |
strip.begin(); | |
strip.show(); | |
} | |
void loop() { | |
int buttonState = digitalRead(BUTTON_PIN); | |
if (buttonState == LOW && !modeButtonPressed) { | |
modeButtonPressed = true; | |
mode = mode < MODES_COUNT ? mode + 1 : 0; | |
} else if (buttonState == HIGH && modeButtonPressed) { | |
modeButtonPressed = false; | |
} | |
switch (mode) { | |
case 0: | |
cycleLoop(2, 100, 20, 359, 100); // Yellow / Orange / fast | |
break; | |
case 1: | |
cycleLoop(5, 200, 0, 120, 75); // Pastel colors cycle / fast | |
break; | |
case 2: | |
cycleLoop(5, 100, 350, 400, 100); // Warm colors cycle / fast | |
break; | |
case 3: | |
stroboLoop(.5, 0, 255, 0, 0); // Red strobo / slow | |
break; | |
case 4: | |
cycleLoop(1, 500, 0, 359, 90); // Strong colors cycle / medium | |
break; | |
case 5: | |
stroboLoop(1, 0, 255, 255, 255); // White strobo / medium | |
break; | |
case 6: | |
// Off | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment