atuline

FastLED and IR test

Oct 30th, 2014
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.87 KB | None | 0 0
  1. /* This example tests both FastLED and the IRRemote.
  2.  
  3. By: Andrew Tuline
  4.  
  5. Date: Oct 30, 2014
  6.  
  7. As of the current 3.1 FastLED library, both FastLED.show() and FastLED.delay() must be commented out in order for the IR to work properly.
  8.  
  9. */
  10.  
  11.  
  12. #include "FastLED.h"
  13. #include "IRremote.h"
  14.  
  15. int RECV_PIN = 9;
  16. IRrecv irrecv(RECV_PIN);
  17. decode_results results;
  18.  
  19.  
  20. #define LED_DT 12
  21. #define COLOR_ORDER GRB
  22. #define LED_TYPE WS2812B
  23. #define NUM_LEDS 100
  24.  
  25. struct CRGB leds[NUM_LEDS];
  26.  
  27. void setup() {
  28.   Serial.begin(57600);
  29.   irrecv.enableIRIn(); // Start the receiver
  30.   LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER >(leds, NUM_LEDS);
  31. }
  32.  
  33. void loop() {
  34. //  FastLED.show();
  35. //  FastLED.delay(5);
  36.  
  37.  
  38.   if (irrecv.decode(&results)) {
  39.     Serial.println(results.value, HEX);                       // Print IR receive results
  40.     irrecv.resume(); // Receive the next value
  41.   }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment