Advertisement
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,
- 30, 100, 0, 0,
- 54, 161, 83, 60,
- 75, 212, 100, 80,
- 100, 255, 175, 150,
- 135, 255, 253, 200,
- 150, 255, 253, 213,
- 179, 255, 253, 255,
- 255, 255, 255, 255
- };
- 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, 0, 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, BRG>(leds, NUM_LEDS);
- pinMode(am1, INPUT);
- }
- //------------LOOP-------------
- void loop() {
- pmCycle();
- FastLED.show();
- amCycle();
- FastLED.show();
- }
- //Functions------------------------------
- void amCycle()
- {
- CRGB colour = ColorFromPalette(myPal1, paletteIndex, maxBrightness, LINEARBLEND);
- fill_solid(leds, NUM_LEDS, colour);
- EVERY_N_MILLISECONDS(1000) {
- while (paletteIndex <=256) {
- 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) {
- while (paletteIndex <= 256) {
- paletteIndex++;
- }
- if (paletteIndex >=255){
- paletteIndex=0;}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement