A few months back I posted an example that used a 44 button IR Remote as an ASCII keyboard.
See: FYI: 44 button IR remote for your projects - General Electronics - Arduino Forum
This example used a library from Adafruit.
I have expanded this to a 17 button IR Remote.
Both are available on eBay from $2 to $5 USD.
I am now using the attached new library “IRremoteNEC” that I wrote to manage both Remotes.
The library comes with example sketches for the two remotes.
This new Library uses interrupts from an IR detector/amplifier to measure bit lengths.
Please respond if you have any suggestion for improvements or if you run into a problem with the library.
//*****************************************************************************
//17 button IR remote
//NEC - IR code
//By: LarryD
//
//This sketch demonstrates interfacing to a 17 button IR remote. http://goo.gl/Jk79FM
//These are commonly available on eBay for $2 USD.
//The remote usually comes with a controller.
//It is an all in one IR detector/amplifier similar to TSOP38238, yours may vary
//**Always confirm the detector/amplifier you have is wired as per YOUR data sheet**
//Remove the detector from the controller for this discussion and wire it to +5V and GND.
//Datasheet for the IR detector: https://www.sparkfun.com/datasheets/Sensors/Infrared/tsop382.pdf
//For wiring, see: https://learn.sparkfun.com/tutorials/ir-control-kit-hookup-guide
//Interrupt 0 (pin D2) is used to achieve fast receive response.
//See also: http://forum.arduino.cc/index.php?topic=289446.msg
//
//=============================================================================
//17 button IR remote
//NEC - IR code
//By: LarryD
//
//For the remote control, see: http://goo.gl/Jk79FM
//
//"IRremoteNEC.cpp IRremoteNEC.h" by LarryD
// PERMISSION TO DISTRIBUTE
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software
// and associated documentation files (the "Software"), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// LIMITATION OF LIABILITY
// The software is provided "as is", without warranty of any kind, express or implied,
// including but not limited to the warranties of merchantability, fitness for a particular
// purpose and noninfringement. In no event shall the authors or copyright holders be liable
// for any claim, damages or other liability, whether in an action of contract,
// tort or otherwise, arising from, out of or in connection with the software
// or the use or other dealings in the software.
//
//IRremoteNEC.cpp(.h) - A class to retrieve IR commands from the 44 and 17 Button IR Remotes
//Tested with Arduino IDE 1.06 on an UNO
//
// Rev 1.00 January 25, 2015 functional code
// Rev 1.01 February 1, 2015 created the library files IRremoteNEC.cpp and .h
// Rev 1.02 April 21, 2015 modified the 44 button remote to a 17 button remote
//**************************************
#include <IRremoteNEC.h>
//We must use an interrupt pin, 2 or 3 on an UNO, Ethernet or ATmega1284
//connect this pin to the IR Receiver Module
//#define interruptPin 3
#define interruptPin 2
//confirm the correct interrupt pin has been selected
#if interruptPin != 2 && interruptPin != 3
#error interruptPin must be 2 or 3!
#endif
IRremoteNEC myRemote(interruptPin); //create the object using this pin
//**************************************
#define tonePin 7 //Piezo speaker is connected to this pin
//*****************************************************************************
//17 button Keypad
const byte buttonCode[18] = {
0x46,0x44,0x40,
0x43,0x15,0x00, //0X00 is not defined
0x16,0x19,0x0D,
0x0C,0x18,0x5E,
0x08,0x1C,0x5A,
0x42,0x52,0x4A
}; //END of buttonCode Array
const byte ASCIIcode[18] = {
// ^ < New line
0x5E,0x3C,0x0A,
// > v nul
0x3E,0x76,0x00,
// 1 2 3
0x31,0x32,0x33,
// 4 5 6
0x34,0x35,0x36,
// 7 8 9
0x37,0x38,0x39,
// * 0 #
0x2A,0x30,0x23
}; //END of ASCIIcode Array
//*****************************************************************************
void setup(void)
{
Serial.begin(115200);
myRemote.beginIR();
}
//************************** E N D s e t u p ( ) *****************************
void loop(void)
{
//**************************************
//Check if we have received a valid IR code yet.
if(myRemote.getIRflag())
{
byte byteRX = myRemote.checkCode();
//If we get a verified button code, convert it to an ASCII code.
if(byteRX)
{
//Scan through the buttonCode Array.
//NOTE: IR remote repeat codes are not returned.
for (int i = 0; i < 18; i++)
{
if (buttonCode[i] == byteRX)
{
tone(tonePin,3400,100);
Serial.print(char(ASCIIcode[i])); //get the ASCII code
//We found it, no need to continue looking.
break;
}
}
} // END of if(byteRX)
//Get ready for the next falling edge.
myRemote.resetIRflag();
} // END of if(myRemote.getIRflag())
//**************************************
// Other loop stuff goes here
}
//************************** E N D l o o p ( ) *****************************
//=============================================================================
// END OF CODE
//=============================================================================
Edit: new version May 20 2015
IRremoteNEC.zip (8.11 KB)