I need to read a potentiometer value from an ATTINY85. I have big fat 10K POT but for this use case I need it to be very small so I used a salvaged 2.4K one, the kind that is soldered directly onto a PCB.

I am using tinkercad to prototype my project and I am facing a very weird problem. Everytime I read from the POT Pin, I get the value of 512 (using the debugger)

Here is a screenshot of my prototype: enter image description here

The goal is to power the circuit and the lamp (does not matter what is there, consider it just a load) with a 9V battery, use a 5V regulator to power the ATTINY85 and use an NPN transistor to turn the lamp/load on or off.

For information, the whole regulator and transistor setup is tested and works like a charm.

Here is the code I wrote for the this case:

void setup()
  pinMode(PB0, INPUT);

int potValue = 0;

void loop()
  potValue = analogRead(PB0);

Not real fancy right? Now no matter what use for the POT, and I tried 2.4K, 10K and up to 100K, the value read by the ATTINY is always 512.

Do you see something wrong in this setup? Could it be a bug in tinkercad? (I'd be surprised though)

I could try and share this circuit within tinkercad if someone would be willing to have a look...

EDIT: I just tried with PB2 as suggested but not the value is always 58: enter image description here

  • Since you never display the reading from the pot, how do you know what it is? Try printing it.
    – Delta_G
    Sep 22, 2020 at 13:20
  • Port PB0 is not an ADC pin on the ATTiny85. Choose PB2, PB3, PB4 or PB5.
    – StarCat
    Sep 22, 2020 at 13:25
  • I know the value of the pot reading because tinkercad has a debugger Sep 22, 2020 at 13:30
  • I'll try another pin straight away Sep 22, 2020 at 13:30
  • 1
    Note that you would need a resistor on the base of the NPN transistor. Sep 22, 2020 at 13:40

1 Answer 1


Port PB0 is not an ADC (analog input) pin on the ATTiny85.

Available pins of the ATTiny85 (from the Atmel ATtiny 25, 45, 85 datasheet):

ATtinyx5 pinoutChoose PB2, PB3, PB4 or PB5 if you need an analog input.

Additional information: When built in TinkerCAD, using PB2 as an analog input does not seem to work correctly and produces a fixed value. Using PB3 did work correctly however. This might be a bug in TinkerCAD.

  • Just tried and I get another weird fixed value: 58... Sep 22, 2020 at 13:36
  • I edited the question so I could upload a picture of the new setup using PB2 and the debugger output Sep 22, 2020 at 13:40
  • Just for fun, I built the same circuit (but simplified) in TinkerCAD and strangely enough I could not get it to work with PB2, but PB3 did work. I guess this is a bug in TinkerCAD. I haven't used it before until today but I'm pretty sure I've built it correctly.
    – StarCat
    Sep 22, 2020 at 14:15
  • Indeed, it works like a charm with PB3! Thanks! Can you add this comment to your answer so I can accept it (I guess it is clearer for future references) Sep 22, 2020 at 14:22
  • I've added the comment to my answer.
    – StarCat
    Sep 22, 2020 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.