/CODE
#include "Prototype.h"
unsigned int IR_Data = 0, x, Var;
unsigned char IR_Count = 0, Sensor_Check = 0, z, i;
bit Flag = 0;
void main()
{
Serial_Init();
TRISB = 0x01; // 0th Bit of PortB as Input ( External Interrupt ) & Remaining Pins as Output
RBPU = 0; // Turn On all Internal Pull Ups
GIE = 1; // Global Interrupt Enable
PEIE = 1; // Phepipheral Interrupt Enable Bit
INTEDG = 0; // Interrupt on Rising Edge of RB0/INT
INTE = 1; // Enables RB0/INT External Interrupt
while( 1 )
{
if( Sensor_Check == 1 )
{
Sensor_Check = 0;
for( i = 0; i < 16; i++)
{
if( ( IR_Data<<i ) & 0x8000 )
Send_Byte( 0x30 );
else Send_Byte( 0x31 );
}
Send_Enter();
IR_Data = 0;
}
INTE = 1; INTF = 0;
}
}
static void interrupt isr( void )
{
INTE = 0; INTF = 0;
while( IR_Count < 0x0E )
{
if( ( !IR ) && ( IR_Count < 0x0E ) )
{
IR_Data|= IR;
IR_Data <<=1;
Delay_IR();
IR_Count++;
}
if( ( IR ) && ( IR_Count < 0x0E ) )
{
IR_Data <<= 1;
IR_Data |= IR;
Delay_IR();
IR_Count++;
}
}
Sensor_Check = 1;
}