User Guide
Determining IR Codes
ThecodebelowwillhelpyoudeterminethevaluesforthesignalsbeingsentfromanIRremote
control.NotethatthecodedoesnotworkforallIRremotesandmayneedtobecustomized.
Copyandpasteallofthecode(initalics)belowintotheArduinowindow(asanew“sketch”).
NotethatthiscodewillonlyworkifyouhavetheIRemotelibrarysuccessfullyinstalled(see
instructionsabove).
#include<IRremote.h>
#include<IRremoteInt.h>
IRrecvirrecv(9);//digitalpin9ontheshieldispermanentlyconnectedtotheIRreceiver
decode_resultsresults;
voidsetup()
{
Serial.begin(9600); //Thisdeterminesthebaudrate
irrecv.enableIRIn();//Enablethereceiver
}
voidloop()
{
if(irrecv.decode(&results))
{
Serial.println(results.value,DEC);//alternativelyuseHEXratherthanDEC
irrecv.resume();//Receivethenextvalue
}
}
Onceyouhaveverifiedanduploadedthecode,opentheserialterminalwithintheArduinoIDE,
keepingtheArduinoconnectedtothecomputer.CovertheIRreceiverwithyourhandfromall
sidesexcepttheonewiththeroundpartwhichfacesoutwards(tolimitIRinterferencefrom
lights,sunandothersources).AimyourIRremoteatthereceiverandpressonebutton.You
shouldseeavalueappearintheserialterminalwindowonlywhenyoupressabutton.Pressthe
buttonafewtimestoensureit’sthecorrectvalue,andtakenoteofitinafile(thebutton,andthe
correspondingcode).
RobotShopInc.www.RobotShop.com