vasilpetrovich
Newbie

I need to recognize a signal from an IR remote, not to use a library for working with IR remotes/receivers. How can when the button is clicked to display its name. I have PIC12F615 microcontroller with this code: code and 5 buttons connected to him and I need recognise which button pressed. I have some code but it gives different hex codes if I pressed the same button. code:
schema:
C++:
const byte IRpin = 2;
volatile boolean remote = false;
volatile unsigned long irCode = 0;
void remoting ()
{
if ( remote )
{
remote = false;
unsigned long T;
for ( byte n = 0; n < 32; n ++ )
{
do
{
T = pulseIn ( IRpin, HIGH, 2200 );
}
while ( T < 64 );
bitWrite ( irCode, n, T > 1120 );
}
}
}
void setup ()
{
Serial.begin ( 9600 );
Serial.println ( "\n\tReady for keyboard reading!\n" );
pinMode ( IRpin, INPUT_PULLUP );
attachInterrupt ( digitalPinToInterrupt ( IRpin ), remoting, FALLING );
}
void loop ()
{
if (irCode)
{
Serial.println (irCode, HEX);
irCode = 0;
}
delay (40);
remote = true;
}
schema: