Hi there,
I have bought the very same chinese sensor. KY-039, but it has not been a good deal!
Have a look at https://www.youtube.com/watch?v=psTa5ZrqAyo or on other project on youtube..
and you can understand that you may wanna get something better than just a led, and IR receiver and two resistors. you may want to amplify and clean the signal here.
BTW here is my two-mins simple attempt to get something useful from this incomplete sensor.
int ledc = 13;
int sensorPin = 0;
int period = 20;
int change, oldvalue, value;
int time = 0;void setup ()
{
pinMode(ledc, OUTPUT);
Serial.begin (9600);
}
void loop ()
{
value = analogRead (sensorPin);
Serial.print (" ");
Serial.println(value);
change = abs(oldvalue - value);
if(change > 1 )
{
Serial.println (change);
time +=1;
}
else
{
time -=1;
if (time < 0)
time = 0;
}if (time > 0)
analogWrite(ledc, 255);
else
analogWrite(ledc,0);oldvalue = value;
delay (period);
}