TCRT1000 Pulse Sensor with Arduino Uno R3.

Hello and good day guys,

I'm currently trying to operate a TCRT1000 (http://www.vishay.com/docs/83752/tcrt1000.pdf) with an Uno R3 but I'm having a little problem with the reading it returns.

I am primarily following this guide I found, both hookup and code;

Here's a copy paste of the code.

int sensor = 0;  
int ledIntensity;
int led = 3;

void setup() {
  Serial.begin(9600);
  pinMode(led,OUTPUT);
}

void loop() {
  sensor = analogRead(0); // I changed this to analogRead(1) as I am using channel 1.
  ledIntensity = map(sensor,30,1023,0,255);
  analogWrite(led,ledIntensity);
  Serial.println(sensor);
  delay(10);
}

I did change the resistor on pin #4 to a 10K instead of 20K as per the video because I was going through the datasheet of the TCRT1000 and it says the collector typically runs on 0.5mA. Just want to note that this is the first time I'm touching electronics, so if I'm interpreting the datasheet wrong it would be great if someone could point that out.

With nothing covering it, the reading is constantly at 1023, and when I put my finger over it, it hovers around 490-510. I am also still trying to understand on how to adapt the code from the guide to what I have. I have a little background in programming (Python) but the problem I face is mainly not knowing how should I approach troubleshooting this situation. What or where I be looking at first. Any general tips on this would be great.

Also just to note an observation, unlike his video, my TCRT1000 doesn't seem to have a LED shinning.

I'm grateful for any help you can provide. Thank you.

That is a really bad datasheet. It is not complete, confusing, and two pins are both called 'C'.

The normal current for the led is 20mA. Can you tell how you have done that ?
The forward voltage drop over the led is about 1.1V. So the resistor should be (5-1.1V/20mA) = 195 ohm
Do you have a resistor from 5V of 180 or 220 ohm to pin A (1) ? And is pin C (2) connected to GND ?

The output of the transistor is very vague.
I think the current to detect is 0.2 to 0.4 mA.
With 10k resistor to 5V, the voltage will be 3V to 1V. That should be okay.
Without something in front of it, it should not be 1023, but about 614.
Use a piece of paper to test it, the value could be about 102 at it lowest.

The Arduino map function was changed, it had trouble with numbers being lower or higher than the output in the past. Are you using the newest Arduino IDE 1.6.5 ?

Keep the led of the sensor at a constant current of 20mA.

  pinMode (ledPin, OUTPUT);
  digitalWrite (ledPin, HIGH);        // turn on led

Remove (or comment out) the analogWrite.

Show your new sketch, and show us a schematic or a photo.