Guest User

Untitled

a guest
Mar 30th, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #include <FastLED.h>
  2. #include <IRLib.h>
  3.  
  4. #define DATA_PIN 12
  5. #define CLOCK_PIN 7
  6. #define NUM_LEDS 61
  7. #define WAIT_TIME 1000
  8. #define COLOR_ORDER BGR
  9.  
  10. uint8_t max_bright = 20;
  11. uint8_t lead_dot = 0;
  12. uint8_t bpm = 40;
  13. uint8_t voldown = 0;
  14. uint8_t volup = 0;
  15.  
  16. CRGB leds[NUM_LEDS];
  17.  
  18. IRrecv My_Receiver(11);//receiver on pin 11
  19. IRdecodeNEC My_Decoder;//Decoder object
  20.  
  21. void setup() {
  22. delay( 3000 ); //safety startup delay
  23. FastLED.addLeds<APA102, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
  24. FastLED.setBrightness(max_bright);
  25. My_Receiver.enableIRIn(); // Start the receiver
  26. Serial.begin(9600);
  27. }
  28.  
  29.  
  30.  
  31. void loop()
  32. {
  33. // FastLED.show();fill_solid(leds, NUM_LEDS, CRGB::Black);
  34. if (My_Receiver.GetResults(&My_Decoder)) {
  35. My_Decoder.decode();
  36. if (My_Decoder.decode_type== NEC) {
  37. switch(My_Decoder.value) {
  38. case 0xFD00FF: //Volume Down
  39. volup = 0;
  40. voldown++;
  41. if(voldown > 1){
  42. voldown = 0;}
  43. // delay(1000);
  44. break;
  45.  
  46. case 0xfd40bf: //volume up
  47. voldown = 0;
  48. volup++;
  49. if(volup > 1){
  50. volup = 0;}
  51. // delay(1000);
  52. break;
  53. }
  54.  
  55. My_Receiver.resume(); //Restart the receiver
  56. }}
  57.  
  58. if(volup == 1) { //Volume up
  59. leds[lead_dot].b = 255;
  60. lead_dot = beatsin8(bpm, 0, NUM_LEDS);
  61. FastLED.show();
  62.  
  63. EVERY_N_MILLISECONDS(20) {
  64. fadeToBlackBy(leds, NUM_LEDS, 64);
  65. }
  66.  
  67. }
  68.  
  69. if(voldown == 1) {//Volume down
  70. leds[lead_dot].g = 255;
  71. lead_dot = beatsin8(bpm, 0, NUM_LEDS);
  72. FastLED.show();
  73.  
  74. EVERY_N_MILLISECONDS(20) {
  75. fadeToBlackBy(leds, NUM_LEDS, 64);
  76. }
  77. }
  78.  
  79. if(voldown == 0 && volup == 0) {//both off
  80. for (int i = 0; i < NUM_LEDS; i++) {
  81. leds[i] = CRGB::Black;
  82. FastLED.show();
  83. //updateLights(WAIT_TIME / 25);
  84. }}
  85.  
  86.  
  87. Serial.print(voldown);
  88. Serial.println();
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment