Last active
November 29, 2018 01:49
-
-
Save chemdoc77/799aadf8c0132e29a8168f6da942d1e7 to your computer and use it in GitHub Desktop.
Basic IR Remote with NeoPixels and Teensy 3.1 Test Sketch by Chemdoc77 Note: Problem occurs when first button push give garbage number and second button push works.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Basic IR Remote with NeoPixels Test Sketch by Chemdoc77 | |
Note: Problem occurs when first button push give garbage number and second button push works. | |
*/ | |
#define FASTLED_ALLOW_INTERRUPTS 0 | |
#include <FastLED.h> | |
#include <IRremote.h> | |
//================= | |
uint8_t RECV_PIN = 10; // For Teensy 3.1 | |
uint32_t firstcode = 100; | |
IRrecv irrecv(RECV_PIN); | |
#define LED_PIN 6 // For Teensy 3.1 | |
#define LED_TYPE NEOPIXEL | |
#define NUM_LEDS 24 // Change to reflect the number of LEDs you have | |
CRGB leds[NUM_LEDS]; | |
int BRIGHTNESS = 50; | |
decode_results results; | |
void setup() | |
{ | |
Serial.begin(115200); | |
irrecv.enableIRIn(); // Start the receiver | |
FastLED.addLeds<LED_TYPE, LED_PIN>(leds, NUM_LEDS); | |
FastLED.setBrightness( BRIGHTNESS ); | |
FastLED.setMaxPowerInVoltsAndMilliamps(5, 1000); | |
set_max_power_indicator_LED(13); | |
fill_solid(leds, NUM_LEDS, CRGB::Black); | |
FastLED.show(); | |
} | |
void loop() { | |
if (irrecv.decode(&results)) { | |
Serial.println("results.value:"); | |
Serial.println(results.value); | |
irrecv.resume(); // Receive the next value | |
} | |
// for Adafruit IR Remote" | |
switch(results.value) { | |
case 16582903: | |
Serial.println("button 1"); | |
cd77_colorwipe_dot(CRGB::Red, 50); | |
break; | |
case 16615543: | |
Serial.println("button 2"); | |
cd77_colorwipe_dot(CRGB::Blue, 50);//Performance_3(); | |
break; | |
case 16599223: | |
Serial.println("button 3"); | |
cd77_colorwipe_dot(CRGB::Green, 50);//Performance_4(); | |
break; | |
//for 44 Button IR Remote | |
case 16724175: | |
Serial.println("DIY 1"); | |
cd77_colorwipe_dot(CRGB::Red, 50); | |
break; | |
case 16756815: | |
Serial.println("DIY 2"); | |
cd77_colorwipe_dot(CRGB::Blue, 50);//Performance_3(); | |
break; | |
case 16740495: | |
Serial.println("DIY 3"); | |
cd77_colorwipe_dot(CRGB::Green, 50);//Performance_4(); | |
break; | |
} | |
} | |
//============================== | |
void cd77_colorwipe_dot(CRGB color, uint8_t wait) { | |
for (uint8_t i = 0; i <NUM_LEDS; i++) { | |
leds[i] = color; | |
FastLED.delay(wait); | |
leds[i] = CRGB::Black; | |
FastLED.show(); | |
if (irrecv.decode(&results)) return; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment