Analogread on Attiny85

Hi all,

I trying to read analog values from pin2 (A2) from my AtTiny85 without any result. Im struggling the whole day with this issue. Changed pins etc, but the result stays 0.

It's powered by my Uno.

My code & configuration:
Attiny85 @ 8 Mhz (BOD disabled)

int value1 =  analogRead(A2);
Serial.println(value1);

I tried to set the analogReference to 0, but also without any result.

What is wrong? please help!!

Thanks!

The pin numbers are different for the different cores.

If you use this core
https://code.google.com/p/arduino-tiny/

then A2 is pin PB4

Thanks for you quick reply.

Oops, I ment A1 for PB2 (tried them all btw). Is this correct?

I've just downloaded the latest (not the Core 2 yet! :wink: ). Now I get responses!!! Thanks!! But ... it seams quite random now.

When I have an unconnected jumper wire to Pin2 (A1), I get some random value (~400) and the next reading ~1023. And then again ~400 and ~1023 again...

Any idea?

KiwiFreaK:
When I have an unconnected jumper wire to Pin2 (A1), I get some random value (~400) and the next reading ~1023. And then again ~400 and ~1023 again...

Any idea?

Sounds perfectly normal to me. Try attaching something to the wire (1.5V battery...)

Yeah! It works!

Try attaching something

...after a many hours of trying many things. I removed wires and code... and it works. You guys saved my day (or whats left :wink: ).

Thanks!