Using IR emitter/reader to scan barcodes with Arduino Uno

Hello everybody,
I am trying to use a HOA6480 Series Barcode Sensor to read barcodes from ID cards with the Arduino Uno serial interface. So far in all the tests i have done, the sensor is not able to give steady readings. The arduino is not able o make anything of the data from the Sensor. Please assist me in finding a way to decode the signals into usable data.

So how have you got it connected and what software are you using. You say you are using serial but you can not simply connect it to a serial port.
How are you scanning the bar code? The data sheet talks of a code on a spinning motor to test it.

I have tried using the pulseIn () function in interrupts to capture the pulse widths and translate that into binary bits but currently it is giving only 3-5 pulse width readings.

This code was used to try and establish the range of pulse widths the commented section would be the segment to convert to binary data representing the barcode.
My apologies for the poor code, very new to coding.

#include <Wire.h>
#include <interrupts.h>
#include <Array.h>


int pin = 2;
volatile unsigned long duration;
volatile int i = 0;
volatile unsigned long data[50];
unsigned char time;
int last,t,bits,a,b,c;
unsigned char inchar;
String bitstring="";
void setup()
{
  Serial.begin(9600);
  a=06;
  b=04;
  c=02;
  pinMode(pin, INPUT);
  attachInterrupt(0, readhigh, RISING);
  attachInterrupt(0, readLOW, FALLING);
  Serial.println("Ready");
}


void loop()
{

  if (i!=0) {
    Serial.print("data print: I = ");
    last=i+1;
    Serial.println(last);
    for (i=0;i<last;)
    {
      time = data [i];
      Serial.print("time= ");
      Serial.println(time);
      i++;
    }
    delay (5000);
    i=0;
  }

}

void readhigh ()
{
  duration = pulseIn(pin, HIGH);
  data[i] = duration;
  i++;
}

void readLOW ()
{
  duration = pulseIn(pin, LOW);
  data[i] = duration;
  i++;
}

/*String join ()
 {
 last=i+1;
 
 for (i=0;i<last;)
 {
 t=data[i];
 if (t>a)
 {bits=111;
 }
 else if (t>b)
 {bits=11;
 }
 else if (t>c)
 {bits=1;
 }
 bitstring += bits;
 i++;
 t=data[i];
 if (t>a)
 {bits=000;
 }
 else if (t>b)
 {bits=00;
 }
 else if (t>c)
 {bits=0;
 }
 bitstring += bits;
 i++;
 }
 i=0;
 return bitstring;
 }
 
 void decode ()
 {
 }
 */

I don't think the pulse in is sutiable for what you need. This is because if you ask for a pulseIn high and the signal is already high it waits until it drops low first before it starts to time the high.
Look more at the way the IR decoding works.

I was trying that, but they work with a constant frequency and pulse width while in this application the pulse width varies with the speed the card is passed over it. keeping in mind that it has to read about 128 bits in each swipe. Thinking to use input capture next but can't figure out how to make it read the high pulse width and low pulse width continuously in one interrupt routine.
Any suggestions?

but they work with a constant frequency and pulse width

No they don't.

I tried with an IR remote example but it gives a different number of pulse on each scan. This samples the input at set intervals checking if there is a high or low then adds the result to an array. The problem is that the barcodes are passed over the reader at varying speeds each time..... any suggestions on how i could go about accounting for this variance in the readings?

You time each pulse and use the ratio of the pulse widths to determine the code rather than the absolute time that IR codes use.