According the data sheet "Photo IC output signals directly connect with C-MOS and TTL" which in my mind tells me that no outside components are needed to make this thing work. Will operate on up to 7 volts (sourcing power from arduino 5 volt pin)
I had the output pin previously connected to a digital pin and was attempting to digitalRead the pin when it was completely obstructed by a business card. My program was acting like I was in and out of the beam. I connected the output pin to an analog pin and read what I was getting out with no other programming operating.
IE analogRead A0 save to X then Serial.print X.
When beam is not obstructed I get a stream of 0s like I would expect. When I block the beam with a business card or anything else i get a stream that looks like this.
I disassembled the sensor looking for any other circuity inside. With the exception of a surface mount resistor value 271 , the led and the sensor there is no other parts inside. here is a copy of the actual code that I used to read this
int x = 0;
const int sensor = A0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
x = analogRead(A0);
Serial.println(x);
}
To the question ladies and gents, what am i missing. I have a basket of these sensors that I recovered from a large copy machine and was hoping I could do something interesting with them. Am I making a noob mistake? I read quite a few of the forum posts looking for a symptom like this. Found something close but that sensor was outputting opposite to mine (high when clear and low when obstructed) so a INPUT_PULLUP wouldn't work here like in that case. Your help would be greatly appreciated
a machine tech
edit: just for grins I tried 4 other sensors and got similar results so at least thats consistent.
amachinetech:
Found something close but that sensor was outputting opposite to mine (high when clear and low when obstructed) so a INPUT_PULLUP wouldn't work here like in that case. Your help would be greatly appreciated
That's not true. It doesn't matter WHEN the sensor pulls low the signal, what matters is that it's an open drain (aka open collector) output, so the sensor pulls low the signal, and relies on an external resistor to pull it up (and that external resistor may indeed be the internal pull-up of the Arduino). Whether it pulls low the output when it's blocked or when it's clear is irrelevant for this. That's just relevant to you when reading the output.
So if I am wrapping my head around this correctly the sensor is pulling the pin low when it is clear and then letting the pin float when it is obstructed making an erattic reading. So by forcing the pin high with INPUT_PULLUP that makes the sensor act as a voltage divider. When the sensor is clear it drives the pin low actively by shorting to ground. When the sensor is blocked it no longer is shorted to ground and then the INPUT_PULLUP takes over and drives the pin HIGH. Well done gents thanks for the clarification. So the true answer is yes you ARE making a noob mistake. Thanks for your assistance.