I am using a simple 2 phototransistor to obtain light intensity readings from Arduino Uno.
My code seems correct.
Yet the values I get range only between 20 and 120 (20 darkness, 120 light).
Why are the numbers in the serial monitor so restricted?
Its the standard voltage divider. Here is the actual picture. I have tried 2 different photodiodes and still the range is 20 to 120. Even if I plug the A0 pin into ground its 120 and if I plug into 5V its 20.
Its so weird, I bought a brand new board, Uno R3, and with exactly the same sketch and the same wiring setup the numbers range from low single digits to >1000. The old boards I guess do not work? The numbers on old board are exactly between 20 and 120, with very little variability in-between. Thanks all for writing to me and trying to help.
It sounds like that board is a member of the Crispy Critters family or at least a cozen. Try the other channels with the resistor from A? to +5 and Ground and see what the readings are. It should be close to the new board, if not you have a fried analog section. Test the digital they may be bad as well. What did you connect to this board, A relay, motor or something like that? Do you have a resistor in the 50K range, try that.
Not only are those wrong they are also upside down. A0 should read around 1023 when connected to Vcc, and around zero when connected to ground.
Its safest to make connections to Vcc or ground through a 10k resistor.
Try the other analog inputs.