Serial communication on Arduino?

I tested a QRD1114 reflective sensor using a voltage meter, and was working great. I was getting good responses from the sensor (one of the sensors I was using had a bad LED which was not working, but the sensor worked fine with an external IR LED that I had laying around.) But as soon as I hooked it up to an analog input pin of my arduino board, and used the serial communications to display the reading from the sensor on the serial monitor, every reading would be 1023 (which should be the highest possible reading) even when there wasn't anything near the sensor. I changed the pin, so I know it isn't a defective pin. I repeated the test with a photo cell and got similar results. what could be the problem, and what can I do about it?

sort by: active | newest | oldest
Show your circuit diagram, for a start.

Steve
Higgs Boson (author)  steveastrouk5 years ago
would it be possible to use a small capacitor (maybe 0.01 uf) to connect it to the analog pin so that it is not directly connected? Would that fix the problem do you think?
No, This is a DC signal - how would it flow through the capacitor.

Steve
Higgs Boson (author)  steveastrouk5 years ago
Yeah I was thinking that maybe you would change the program so that the output would be based on how fast the capacitor charges and discharges, but I don't think that would work very well.
Higgs Boson (author)  steveastrouk5 years ago
Here is the diagram. sorry for my messy handwriting.
IMG_0356.JPG
Ah ! A completely wrong circuit......

Do this:

Connect a 4.7K resistor from the phototransistor emitter to ground. Connect the arduino pin to the emitter.


Steve
Higgs Boson (author)  steveastrouk5 years ago
I tried the new circuit, and it didn't help. Do you think that it would be better just to connect the emitter from the phototransisitor to the base of a switching transistor and then just connect the transistor tho the power and a digital pin?
No.

Your circuit now looks OK, but is the ground of this connected to the ground of the arduino ?

You may have to alter the resistor values to get decent results. Make the 68 Ohm bigger.

Steve
Higgs Boson (author)  steveastrouk5 years ago
The ground is connected to the ground on the arduino.
Change the circuit, put the resistor from collector to the 5V line, connect the emitter to ground, connect the arduino to the collector. This configuration has a higher gain than the other circuit, but the output is never less than a volt or so.

Steve
Higgs Boson (author)  steveastrouk5 years ago
Wow! works loads better now! thank you for all of your help.
Higgs Boson (author)  steveastrouk5 years ago
sop the circuit would be this right?
IMG_0357.JPG
frollard5 years ago
Okay, are you talking to the sensor with SERIAL or are you reading the analog value from the sensor?

http://arduino.cc/en/Tutorial/AnalogInOutSerial

What happens when you use this code?
Higgs Boson (author)  frollard5 years ago
the read out stays at 1023 still. works fine with pots though.
that tells me the sensor isn't putting out a variable voltage between 0 and 5 volts. Does it have a dc bias? (like outputting between 3-8 volts for max to min readings)
Higgs Boson (author)  frollard5 years ago
I don't know, but with my voltage meter it was saying that with 5v when a white object was right above it it was a little under 5 volts, and just over 0 when there was nothing due to ambient light. It seems that the sensor is working fine without the arduino, it is getting it to work with the arduino that is giving me trouble. the examples for serial monitor didn't seem to be working with the LDR, bur as soon as I connected a regular resistor it was consistant, and when it was hooked up to the wiper pin on a pot it worked great. could it be something with the code? I tried the example you gave me, and nothing changed. have you ever hooked up an IR sensor to arduino before? None of the tutorials are very helpful.
Higgs Boson (author) 5 years ago
Its been working fine with resistors (other than photoresistors) and potentiometers. But with the LDRs and the photo transistor, it either stays at the largest value possible, or goes from a few values of 0 to a larger value then 1023 and back down in a predictable wave pattern. (I forgot to mention this in the question.