Please use the code button (#) to tag code
void loop()
{
int pin = 2;
int highs[42];
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
delay(10); <<<<< should be at least 18 ms !!!! See figure 3 page 6
digitalWrite(pin, HIGH);
delayMicroseconds(30); <<< should be 20-40 msec, OK I guess
pinMode(pin, INPUT);
for (int i=0; i<41; i++) [color=red] // there are 41 pulses 0..40 not 42 ! [/color]
{
highs[i] = pulseIn(pin, HIGH);
}
}
That said, you correctly detect the 80 mu pulse. and the other pulses
you have filled the array highs[]; now you need code to convert this to bytes, would look something like this partial code
byte RHI;
byte RHD;
byte TI;
byte TD;
byte CRC;
for (int i=1; i< 9; i++)
{
RHI = RHI * 2;
if (highs[i] > 50) RHI = RHI + 1; // add a one bit; in short RHI++;
}
for (int i=9; i< 17; i++)
{
RHD = RHD * 2;
if (highs[i] > 50) RHD = RHD + 1;
}
for (int i=17; i< 25; i++)
{
TI= TI* 2;
if (highs[i] > 50) TI = TI + 1;
}
for (int i=25; i< 33; i++)
{
TD= TD * 2;
if (highs[i] > 50) TD= TD+ 1;
}
for (int i=33; i< 41; i++)
{
CRC= CRC * 2;
if (highs[i] > 50) CRC= CRC + 1;
}
Serial.println(RHI, DEC);
Serial.println(RHD, DEC);
Serial.println(TI, DEC);
Serial.println(TD, DEC);
Serial.println(CRC, DEC);