Advertisement
Guest User

Untitled

a guest
May 1st, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.71 KB | None | 0 0
  1. #include <FastLED.h>
  2. #define NUM_LEDS 50
  3. #define LED_PIN 5
  4. #define BRIGHTNESS 75
  5. #define LED_TYPE NEOPIXEL
  6. #define COLOR_ORDER GRB
  7. #define UPDATES_PER_SECOND 75
  8. CRGB ledStrip[NUM_LEDS];
  9. CRGBPalette16 currentPalette;
  10. TBlendType currentBlending;
  11. const int pin12 = 12;
  12. const int pin11 = 11;
  13. const int pin10 = 10;
  14. const int pin9  =  9;
  15. const int pin8  =  8;
  16. const int pin7  =  7;
  17. const int pin6  =  6;
  18. const int pin5  =  5;
  19.  
  20. void setup() {
  21.   // put your setup code here, to run once:
  22.   delay(3000);
  23.   FastLED.addLeds<LED_TYPE, LED_PIN>(ledStrip, NUM_LEDS);
  24.   FastLED.setBrightness(BRIGHTNESS);
  25.   currentPalette = RainbowStripeColors_p;
  26.   currentBlending = NOBLEND;
  27.   pinMode(pin12, INPUT_PULLUP);
  28.   pinMode(pin11, INPUT_PULLUP);
  29.   pinMode(pin10, INPUT_PULLUP);
  30.  
  31. }
  32.  
  33. void StripFill (CRGB color, uint8_t from, uint8_t to) {
  34.   for (uint8_t i = from; i <= to; i++) {
  35.     ledStrip[i] = color;
  36.   }
  37. }
  38.  
  39. /*void leftStripWipe {
  40.   for(int i = NUM_LEDS; i++) {
  41.     ledStrip[i] = CRGB::Red;
  42.     FastLED.show();
  43.     ledStrip[i] = CRGB::Red;
  44.     FastLED.show();
  45.     delay(5);
  46.   }
  47. }*/
  48.  
  49. void loop() {
  50.   // put your main code here, to run repeatedly:
  51.   int d12 = digitalRead(pin12);
  52.   int d11 = digitalRead(pin11);
  53.   int d10 = digitalRead(pin10);
  54.   if (d12 == 1 && d11 == 1 && d10 == 1) {
  55.     StripFill(CRGB::Black, 0, 50);
  56.     FastLED.show();
  57.   }
  58.  
  59.   if (d12 == 0) {
  60.     for (int i = 0; i < NUM_LEDS; i++) {
  61.       ledStrip[i] = CRGB::Red;
  62.       FastLED.show();
  63.       ledStrip[i] = CRGB::Red;
  64.       FastLED.show();
  65.     }
  66.   if (d10 == 0) {
  67.     for(int i = NUM_LEDS-1; i >= 0; i--)
  68.     ledStrip[i] = CRGB::Blue;
  69.     FastLED.show();
  70.     ledStrip[i] = CRGB::Blue;
  71.     FastLED.show();
  72.     delay(5);
  73.   }
  74.   }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement