analogRead() returning no 0

Hello! I'm playing with IR receiver.. it is photo transistor. The problem is if I disconnect all (except usb) and look into Serial Monitor analogRead(A0) returning strange values (about ~200-300) but not 0. Why? :slight_smile:

the input is floating (definition of nothing connected) therefore does not have a defined voltage applied to it.

Can you post your code and a schematic you use?

no schema at all .. just arduino connected to usb ... code..

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
}

void loop() {
  sensorValue = analogRead(A0);            
  Serial.print("sensor = " );
Serial.print(sensorValue);   
}

If it only prints 0's it could be that the A0 line is grounded somehow. Can you check the other analog ports?

how sensor is connected?

if sensor make ground connection when it got ir try with these two lines....

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
pinMode(A0, INPUT)
digitalWrite(A0, HIGH) 
}

The analog pin is not connected to anything and the pin mode is not set. The reading should float and be about good for a poor random number generator.

pinMode(A0, INPUT)
digitalWrite(A0, HIGH)

Is no good because it makes the analogue input into a digital input and enables the internal pull up resistor.

See:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html
About floating inputs.