Skip to content

Instantly share code, notes, and snippets.

@gbaptista
Created November 17, 2019 01:14
Show Gist options
  • Save gbaptista/614bd608e6cd0db31c926f5efa395c6f to your computer and use it in GitHub Desktop.
Save gbaptista/614bd608e6cd0db31c926f5efa395c6f to your computer and use it in GitHub Desktop.
How to send the detected button code using the https://github.com/z3t0/Arduino-IRremote library.
#include <IRremote.h>
int infraRedReceiverPin = 8;
IRrecv infraRedReceiver(infraRedReceiverPin);
decode_results infraRedReceiverResults;
void setup() {
Serial.begin(9600);
infraRedReceiver.enableIRIn();
}
void loop() {
if (infraRedReceiver.decode(&infraRedReceiverResults)) {
switch(infraRedReceiverResults.decode_type) {
case RC5: printDemo("sendRC5"); break;
case RC6: printDemo("sendRC6"); break;
case NEC: printDemo("sendNEC"); break;
case SONY: printDemo("sendSony"); break;
case PANASONIC: printDemo("sendPanasonic"); break;
case JVC: printDemo("sendJVC"); break;
case SAMSUNG: printDemo("sendSAMSUNG"); break;
case WHYNTER: printDemo("sendWhynter"); break;
case AIWA_RC_T501: printDemo("sendAiwaRCT501"); break;
case LG: printDemo("sendLG"); break;
case SANYO: printDemo("sendSanyo"); break;
case MITSUBISHI: printDemo("sendMitsubishi"); break;
case DISH: printDemo("sendDISH"); break;
case SHARP: printDemo("sendSharp"); break;
case DENON: printDemo("sendDenon"); break;
case PRONTO: printDemo("sendPronto"); break;
case LEGO_PF: printDemo("sendLegoPowerFunctions"); break;
default:
Serial.print(infraRedReceiverResults.decode_type);
Serial.print(" | ");
Serial.print(infraRedReceiverResults.value, HEX);
Serial.print(" | ");
Serial.println(infraRedReceiverResults.bits);
}
infraRedReceiver.resume();
}
}
void printDemo(const char *functionName){
Serial.print(functionName);
Serial.print(functionName);
Serial.print("(0x");
Serial.print(infraRedReceiverResults.value, HEX);
Serial.print(", ");
Serial.print(infraRedReceiverResults.bits);
Serial.println(");");
}
#include <IRremote.h>
IRsend irsend;
void setup()
{
}
void loop() {
// Send the code:
irsend.sendSAMSUNG(0xB24D7B84, 32);
// Wait 10 seconds to send it again:
delay(10000);
}
irsend.sendNEC(0x20DF22DD, 32);
irsend.sendNEC(0x20DFE01F, 32);
irsend.sendSAMSUNG(0xB24D7B84, 32);
irsend.sendNEC(0x20DFC23D, 32);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment