analogRead return always max value (1023)

dear Colleagues,

I attach schema and source code .
Help me Or I will become a crazy. :o

Many Thanks

Hi, you appear to be using an Arduino simulator. Try a real Arduino. If that does not function correctly, then ask here for help. If you do, post your full sketch using code tags and a complete schematic.


Besides, you didn't even post the whole schematic it's supposedly looking at, just part of it. From what I see, that pin could very well be at 5V - I figure it's gotta be pretty close to 5v, since you've got it on the emitter of an NPN transistor, and 5v on the base of that transistor...

But as PaulRB noted above, arduino simulators are not really trustworthy - and you haven't posted the code anyway, only part of it.

I have created a simple project for this issue.
The code:

void setup() {
void loop() //----( LOOP: RUNS CONSTANTLY )----
int val =analogRead(A0);

The schema is attach.

We do real hardware here. Take up the simulator issue with the simulator folks

1 Like


On that page:

Do not analog pins work?

I tested this simple sketch

int analogpin = A1;

int val = 0;
void setup () {
// Put your setup code here, to run once:
Serial.begin (9600);

void loop () {
// Put your main code here, to run repeatedly:
val = analogRead (analogpin);
Serial.println (val);


but it read in 1023 for all value of input voltage

I suggest you contact the authors of the simulator.

If I were you I would use a real Arduino. People have enough trouble getting them to work, without having to debug problems with simulators as well.

Very useful your answer. :).
I have updated the simulation library from that link and now works fine.!
Many Thanks!

Thank you so much for the link you provided sir Nickgammon, it works perfectly now