User manual
We create a NeoPixel strip with one pixel connected to pin 6. Also create a receiver object
connected to pin 11 and a decoder object. Reinitialize the pixel strip and the IR receiver in the setup
routine. Then in the main loop continuously test the receiver to see if it has received many IR
signals. If My_Receiver.GetResults returns true then we decode the data. We are using the Adafruit
Mini Remote we used earlier. It used the NEC protocol so we make sure that we actually received
NEC protocol data. Then we use a switch statement to test various 32-bit hex values against the
decoded data in My_Decoder.value.
After we have set the pixel color based on the received value, we need to call strip.show() to
#include <Adafruit_NeoPixel.h>
#include <IRLib.h>
IRrecv My_Receiver(11);//receiver on pin 11
IRdecode My_Decoder;//Decoder object
//One NeoPixel connected to pin six
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1,6,NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
My_Receiver.enableIRIn(); // Start the receiver
}
void loop() {
if (My_Receiver.GetResults(&My_Decoder)) {
My_Decoder.decode();
if (My_Decoder.decode_type== NEC) {
switch(My_Decoder.value) {
case 0xfd00ff: //Volume Down
strip.setPixelColor(0,255,0,0);//Red
break;
case 0xfd807f: //Play/Pause
strip.setPixelColor(0,0,255,0);//Green
break;
case 0xfd40bf: //Volume Up
strip.setPixelColor(0,0,0,255);//Blue
break;
}
strip.show();
My_Receiver.resume(); //Restart the receiver
}
}
}
© Adafruit Industries https://learn.adafruit.com/using-an-infrared-library Page 12 of 23