Advertisement
Guest User

Untitled

a guest
Sep 20th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.01 KB | None | 0 0
  1. #include "FastLED/FastLED.h"
  2.  
  3. /*#include <FastLED.h>
  4. ^^Above is for Arduino/Codebender^^ */
  5.  
  6. int pinled = D7;
  7.  
  8. const int frameRate = 30;
  9.  
  10. /*  We use 5 known colours which are each expanded to
  11.  *  16 colours in the palette. Palettes have a maximum
  12.  *  of 256 colours but we calculate the size of our
  13.  *  smaller palette.
  14.  */
  15. const int paletteSize = 5 * 16;
  16.  
  17. /*  We fill the palette with our 5 aurora colours. The
  18.  *  sixth colour is a copy of the first which allows
  19.  *  for smooth cyclic transitions.
  20.  *  The remainder of the palette is zero-padded.
  21.  */
  22. using namespace NSFastLED; //Added for Particle Photon build due to FastLED in the community libraries includes a C++ namespace
  23. const CRGBPalette16 auroraPalette(
  24.   CRGB(20,232,30),
  25.   CRGB(0,234,141),
  26.   CRGB(1,126,213),
  27.   CRGB(181,61,255),
  28.   CRGB(141,0,196),
  29.   CRGB(20,232,30),
  30.   0,
  31.   0,
  32.   0,
  33.   0,
  34.   0,
  35.   0,
  36.   0,
  37.   0,
  38.   0,
  39.   0
  40. );
  41.  
  42. CRGB led;
  43.  
  44. void setup() {
  45.   FastLED.addLeds<NEOPIXEL, 6>(&led, 1); // attach our one NeoPixel LED to pin 6
  46.   Spark.function("tweet", twittermessage);
  47.   //particle.function("tweet", twittermessage);
  48.   pinMode(pinled, OUTPUT); // Set up onboard LED as a "pre" notification
  49.   FastLED.setBrightness(63); // so we don't blind ourselves
  50.  
  51.  
  52. }
  53.  
  54.  
  55.  
  56. //Standard Loop turn CRGB LED off (Black)
  57. void loop() {
  58.         led = CRGB::Black;
  59.         FastLED.show();
  60.         delay(30);
  61. }
  62.  
  63.  
  64.  
  65.  
  66. // this function automagically gets called upon a tweet mention
  67. int twittermessage(String ignore)
  68. {
  69.     digitalWrite(pinled, HIGH); // Turn on On-board LED as "pre-notification"
  70.     delay(1800000); //Wait 30 mins (1800000 Milliseconds) as @auroraalerts predicts ~50 mins before events )
  71.     digitalWrite(pinled, LOW); // Turn off On-board LED
  72.     //Turn on Neopixel
  73.     while(1){
  74.     static int index = 0;
  75.     if (++index >= paletteSize) index = 0;
  76.  
  77.     led = ColorFromPalette(auroraPalette, index, 255, LINEARBLEND); //Changed BLEND to LINEARBLEND
  78.  
  79.     FastLED.show();
  80.     FastLED.delay(1000 / frameRate);
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement