Created
April 26, 2019 19:59
-
-
Save ckiee/d3cc030583e0cdf33a4f374f559a4492 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 <FastLED.h> | |
#include <EEPROM.h> | |
// How many leds in your strip? | |
#define NUM_LEDS 60 | |
// For led chips like Neopixels, which have a data line, ground, and power, you just | |
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock, | |
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN | |
#define DATA_PIN 3 | |
#define CLOCK_PIN 13 | |
#define HIGHEST_OPTION 2 | |
// Define the array of leds | |
CRGB leds[NUM_LEDS]; | |
int option = EEPROM.read(1); | |
void setup() { | |
Serial.begin(9600); | |
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); | |
if (option >= HIGHEST_OPTION) { | |
EEPROM.write(1, 0); | |
option = 0; | |
} else { | |
EEPROM.write(1, option + 1); | |
option++; | |
} | |
option = option * 3; | |
FastLED.showColor(CRGB(EEPROM.read(option + 2),EEPROM.read(option + 3),EEPROM.read(option + 4))); | |
} | |
void loop() { | |
if (Serial.available() > 0) { | |
int r = Serial.parseInt(); | |
int g = Serial.parseInt(); | |
int b = Serial.parseInt(); | |
EEPROM.write(option + 2, r); | |
EEPROM.write(option + 3, g); | |
EEPROM.write(option + 4, b); | |
FastLED.showColor(CRGB(r,g,b)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment