Read IR signal with Arduino and a Photodiode

Hello

As part of a school project, I have to read an IR signal from a TV remote with just a plain photodiode and not use any IR receiver / sensor. But it seems to be somewhat difficult to process a 38 kHz signal and furthermore to transform the small change in current of a photodiode into a digital signal.

You see in the attachment what I came up with so far. At least there seems to be some kind of a digital signal incoming that triggers falling and rising interrupts on pin 2 (arduino micro). However, the number of pulses within 70ms (thats roughly how long a signal should take) varies. Sometime I count about 860 pulses in the given time and other times I just count about 35 pulses or something between.

Since I expect a deterministic count of pulses of a commercial TV remote I guess I did something wrong. Maybe I need to amplify the signal of the photodiode? I have never worked with transistors before and looking for your help.

Best regards
Samuel

 // COUNT THE NUMBER OF PULSES OF MY TV REMOTE WITHIN 70ms.

int pd = 2; // Photodiode to digital pin 2

volatile int prev_time = 0;
volatile int counter = 0;

void setup()
{
	attachInterrupt(digitalPinToInterrupt(pd), falling, FALLING);
	
	while (!Serial);
	Serial.println("Ready to read IR signal!");
}

void loop()
{
}

void falling()
{
	attachInterrupt(digitalPinToInterrupt(pd), rising, RISING);
	prev_time = millis();
}

void rising()
{
	counter++;
	int delta = millis() - prev_time;
	if (delta >= 70)
	{
		Serial.println(counter);
		counter = 0;
		attachInterrupt(digitalPinToInterrupt(pd), falling, FALLING);
	}
}