Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //sunrise to sunset from timing sketch
- #define FASTLED_INTERNAL
- #include <FastLED.h>
- #include <Wire.h>
- #define NUM_LEDS 6
- #define DATA_PIN 6
- #define am1 7
- int am1state = 0;
- uint16_t currentPixel = 0;
- uint16_t led = 0;
- byte maxBrightness = 150;
- //----------PALETTES-----------
- DEFINE_GRADIENT_PALETTE (am_gp) { // 0000 TO 1200
- 0, 0, 0, 0, //black
- 18, 0, 0, 0, //dark red
- 56, 161, 83, 0, //orange
- 115, 212, 202, 0, //dark yellow
- 179, 255, 253, 213, //bright yellow
- 255, 255, 255, 255, //white
- };
- DEFINE_GRADIENT_PALETTE (pm_gp) { // 1200 To 0000
- 0, 255, 255, 255, //white
- 18, 255, 253, 213, //bright yellow
- 56, 212, 202, 0, //dark yellow
- 115, 161, 83, 0, //orange
- 179, 98, 0, 0, //dark red
- 255, 0, 0, 0 , //black}
- };
- CRGBPalette16 myPal1 = am_gp;
- CRGBPalette16 myPal2 = pm_gp;
- struct CRGB leds[NUM_LEDS];
- static uint8_t paletteIndex = 0;
- //------------SETUP-------------
- void setup() {
- FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
- pinMode(am1, INPUT);
- }
- //------------LOOP-------------
- void loop() {
- amCycle();
- FastLED.show();
- pmCycle();
- FastLED.show();
- }
- //Functions------------------------------
- void amCycle()
- {
- CRGB colour = ColorFromPalette(myPal1, paletteIndex, maxBrightness, LINEARBLEND);
- fill_solid(leds, NUM_LEDS, colour);
- EVERY_N_MILLISECONDS(1000) {
- if (paletteIndex < 255) {
- paletteIndex++;
- }
- if (paletteIndex == 255) {
- paletteIndex = 0;
- }
- }
- }
- //*****************************************
- void pmCycle()
- {
- CRGB colour2 = ColorFromPalette(myPal2, paletteIndex, maxBrightness, LINEARBLEND);
- fill_solid(leds, NUM_LEDS, colour2);
- EVERY_N_MILLISECONDS(1000) {
- if (paletteIndex < 255) {
- paletteIndex++;
- }
- if (paletteIndex >= 255) {
- paletteIndex = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment