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:
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);
delay(100);
}
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: