int pd=2; //Photodiode to digital pin 2 int senRead=0; //Readings from sensor to analog pin 0 int blanks=0; int marks=0; int threshold=500; //Threshold of IR pulse (may need to adjust) void setup() { pinMode(pd,OUTPUT); digitalWrite(pd,HIGH); //supply 5 volts to photodiode Serial.begin(9600); //set serial monitor baund rate of 9600 } void loop() { int val=analogRead(senRead); //variable to store values from the photodiode if(val <= threshold) { if (blanks>1000) { Serial.println("IR Code Received"); } marks++; blanks=0; } else { if (marks>1000) { Serial.println("IR Code Received"); } marks=0; blanks++; } }