c_cpp 使用IRLib by Chris Young的IR Extender http://cyborg5.com - 适用于NEC代码设备
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了c_cpp 使用IRLib by Chris Young的IR Extender http://cyborg5.com - 适用于NEC代码设备相关的知识,希望对你有一定的参考价值。
/*
IR Extender using IRLib by Chris Young http://cyborg5.com
Works well with NEC code devices
*/
#include <IRLib.h>
int RECV_PIN = 11;
IRrecv My_Receiver(RECV_PIN);
IRsend My_Sender;
IRdecode My_Decoder;
unsigned int Buffer[RAWBUF];
void setup()
{
Serial.begin(9600);
My_Receiver.enableIRIn(); // Start the receiver
My_Decoder.UseExtnBuf(Buffer);
}
void loop() {
if (My_Receiver.GetResults(&My_Decoder)) {
My_Decoder.decode();
// delay(150); // Do not delay since it makes repeat codes stop working
if (My_Decoder.value == 0xFFFFFFFF) {
Serial.println("Repeat code");
} else {
Serial.print("Protocol 0x");
Serial.println(My_Decoder.decode_type, HEX);
Serial.print("Code 0x");
Serial.println(My_Decoder.value, HEX);
Serial.println(My_Decoder.bits);
}
My_Sender.send(My_Decoder.decode_type , My_Decoder.value, My_Decoder.bits);
My_Receiver.enableIRIn(); // Important, otherwise I can no more receive
My_Receiver.resume(); // Restart the receiver so it can be capturing another code
}
}
/*
IR Extender using IRLib by Chris Young https://github.com/cyborg5/IRLib/
Works well with NEC code devices. Example with SAT receiver, beamer, and color LED bulb.
01-2015
*/
#include <IRLib.h>
int RECV_PIN = 11;
IRrecv My_Receiver(RECV_PIN);
IRsend My_Sender;
IRdecode My_Decoder;
unsigned int Buffer[RAWBUF];
unsigned int color = 0; // The inde to the colors[] array
unsigned int last_func = 0; // We use this to implement repeat codes
// IR-controlled LED codes from
// Magic Lighting Remote Controller
// Protocol 0x1, 32 bytes
uint32_t light[] = {
0xFFA05F, 0xFF20DF, 0xFF609F, 0xFFE01F,
0xFF906F, 0xFF10EF, 0xFF50AF, 0xFFD02F,
0xFFB04F, 0xFF30CF, 0xFF708F, 0xFFF00F,
0xFFA857, 0xFF28D7, 0xFF6897, 0xFFE817,
0xFF9867, 0xFF18E7, 0xFF58A7, 0xFFD827,
0xFF8877, 0xFF08F7, 0xFF48B7, 0xFFC837
};
uint32_t colors[] = {
0xFF906F, 0xFFB04F, 0xFFA857, 0xFF9867, 0xFF8877,
0xFF10EF, 0xFF30CF, 0xFF28D7, 0xFF18E7, 0xFF08F7,
0xFF50AF, 0xFF708F, 0xFF6897, 0xFF58A7, 0xFF48B7
};
void increment_color() {
Serial.println("Increment color");
if (color == 14) {
color = 0;
}
else {
color++;
}
Serial.println(colors[color], HEX);
delay(100);
My_Sender.send(0x1 , colors[color], 32);
last_func = 1;
}
void decrement_color() {
Serial.println("Decrement color");
if (color == 0) {
color = 14;
}
else {
color--;
}
Serial.println(colors[color], HEX);
delay(100);
My_Sender.send(0x1 , colors[color], 32);
last_func = 2;
}
void setup()
{
//delay(6000);
//My_Sender.send(0x1 , 0xFD9A65, 32); // Switch of the SAT receiver when the Arduino is powered on; since the beamer is still off at that point
Serial.begin(9600);
My_Receiver.enableIRIn(); // Start the receiver
My_Decoder.UseExtnBuf(Buffer);
}
void loop() {
if (My_Receiver.GetResults(&My_Decoder)) {
My_Decoder.decode();
// delay(150); // Do not delay since it makes repeat codes stop working
if (My_Decoder.value == 0xFFFFFFFF) {
Serial.println("Repeat code");
Serial.println(last_func);
if (last_func == 1) {
increment_color();
}
if (last_func == 2) {
decrement_color();
}
} else {
last_func = 0;
Serial.print("Protocol 0x");
Serial.println(My_Decoder.decode_type, HEX);
Serial.print("Code 0x");
Serial.println(My_Decoder.value, HEX);
Serial.println(My_Decoder.bits);
}
if (My_Decoder.value == 0xFD9A65) {
// If we receive a SAT ON/OFF code, then we send BEAMER ON/OFF codes as well
My_Sender.send(0x1 , 0x10C8E11E, 32);
delay(250);
My_Sender.send(0x1 , 0x10C8E11E, 32);
delay(250);
My_Sender.send(0x1 , 0x10C8E11E, 32);
// And we set smooth LED lighting
delay(100);
My_Sender.send(0x1 , light[23], 32);
}
else if (My_Decoder.value == 0xFDB04F) {
increment_color();
}
else if (My_Decoder.value == 0xFD8877) {
decrement_color();
}
else
{
if (last_func == 0) {
My_Sender.send(My_Decoder.decode_type , My_Decoder.value, My_Decoder.bits);
}
}
My_Receiver.enableIRIn(); // Important, otherwise I can no more receive
My_Receiver.resume(); // Restart the receiver so it can be capturing another code
}
}
/*
IR Extender using IRLib by Chris Young http://cyborg5.com
Works well with NEC code devices. Example with SAT receiver, beamer, and color LED bulb.
01-2015
*/
#include <IRLib.h>
int RECV_PIN = 11;
IRrecv My_Receiver(RECV_PIN);
IRsend My_Sender;
IRdecode My_Decoder;
unsigned int Buffer[RAWBUF];
// IR-controlled LED codes from
// Magic Lighting Remote Controller
// Protocol 0x1, 32 bytes
uint32_t light[] = {
0xFFA05F, 0xFF20DF, 0xFF609F, 0xFFE01F,
0xFF906F, 0xFF10EF, 0xFF50AF, 0xFFD02F,
0xFFB04F, 0xFF30CF, 0xFF708F, 0xFFF00F,
0xFFA857, 0xFF28D7, 0xFF6897, 0xFFE817,
0xFF9867, 0xFF18E7, 0xFF58A7, 0xFFD827,
0xFF8877, 0xFF08F7, 0xFF48B7, 0xFFC837
};
void setup()
{
delay(6000);
My_Sender.send(0x1 , 0xFD9A65, 32); // Switch of the SAT receiver when the Arduino is powered on; since the beamer is still off at that point
Serial.begin(9600);
My_Receiver.enableIRIn(); // Start the receiver
My_Decoder.UseExtnBuf(Buffer);
}
void loop() {
if (My_Receiver.GetResults(&My_Decoder)) {
My_Decoder.decode();
// delay(150); // Do not delay since it makes repeat codes stop working
if (My_Decoder.value == 0xFFFFFFFF) {
Serial.println("Repeat code");
} else {
Serial.print("Protocol 0x");
Serial.println(My_Decoder.decode_type, HEX);
Serial.print("Code 0x");
Serial.println(My_Decoder.value, HEX);
Serial.println(My_Decoder.bits);
}
My_Sender.send(My_Decoder.decode_type , My_Decoder.value, My_Decoder.bits);
if (My_Decoder.value == 0xFD9A65) {
// If we receive a SAT ON/OFF code, then we send BEAMER ON/OFF codes as well
My_Sender.send(0x1 , 0x10C8E11E, 32);
delay(250);
My_Sender.send(0x1 , 0x10C8E11E, 32);
delay(250);
My_Sender.send(0x1 , 0x10C8E11E, 32);
// And we set smooth LED lighting
delay(100);
My_Sender.send(0x1 , light[23], 32);
}
My_Receiver.enableIRIn(); // Important, otherwise I can no more receive
My_Receiver.resume(); // Restart the receiver so it can be capturing another code
}
}
以上是关于c_cpp 使用IRLib by Chris Young的IR Extender http://cyborg5.com - 适用于NEC代码设备的主要内容,如果未能解决你的问题,请参考以下文章
Can't exit loop in Deaf Grandma from Learn to Program by Chris Pine
给我找找chris garneau的relief的中文歌词?