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.