Skip to content

Instantly share code, notes, and snippets.

@jpliew
Created April 9, 2020 00:45
Show Gist options
  • Save jpliew/dde009af083d21e6e0c429a1ec6dfdf8 to your computer and use it in GitHub Desktop.
Save jpliew/dde009af083d21e6e0c429a1ec6dfdf8 to your computer and use it in GitHub Desktop.
IRRemote
#include <IRremote.h>
//Variables:
IRrecv irrecv(10); //Set up the IR Reciever, call it irrecv and attach it to the correct pin
decode_results results; //Set up a variable to hold the results
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
irrecv.blink13(true); //Blinks the LED on the Arduino board as it gets data from the remote.
}
void loop() {
// put your main code here, to run repeatedly:
if (irrecv.decode(&results)) {
String tmp = (String)results.value;
if (tmp == "4294967295") //This value tells the Arduino that the previous button is still active.
{
Serial.println("Button still active."); //Report to the serial monitor the last button was still held down
}
else {
//Serial.println(results.value, HEX); //A new button has been pressed with the value shown.
switch(results.value) // formatted to be less 'long'
{
case 0xFF6897: Serial.println(" 0 "); break;
case 0xFF30CF: Serial.println(" 1 "); break;
case 0xFF18E7: Serial.println(" 2 "); break;
case 0xFF7A85: Serial.println(" 3 "); break;
case 0xFF10EF: Serial.println(" 4 "); break;
case 0xFF38C7: Serial.println(" 5 "); break;
case 0xFF5AA5: Serial.println(" 6 "); break;
case 0xFF42BD: Serial.println(" 7 "); break;
case 0xFF4AB5: Serial.println(" 8 "); break;
case 0xFF52AD: Serial.println(" 9 "); break;
default: Serial.println(" other button ");
}
}
irrecv.resume(); // Receive the next value
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment