Go Down

Topic: ATtiny85 20PU analogread (Read 1 time) previous topic - next topic


Mar 17, 2013, 10:16 pm Last Edit: Mar 18, 2013, 03:01 am by jobard Reason: 1
Hi guys:

I'm new to Arduino and discover the ATtiny85 world maybe a bit early in my learning process.

I'm using that page to program my ATtiny85:

I'm using my Arduino 1.0 to program the ATtiny:

I had problem with a small prototype I have build which use a small potentiometer 25kOhms to configure some values.

So I've created a small test that probe the potentiometer.

My problem is that the analogRead seems to always return the same value on the ATtiny whatever the position of the potentiometer. When I connect the analogIntervalPin on the ground, instead of getting a 0 I get a reading a value greater than zero. I've also connect it on +5v and get the same high value. I cannot figure out what is the value but looks constant. I always get the led blinking 9 times. see code below.

I dont really know how to debug that so I've use a led to get some feedback.

Any idea what I may doing wrong?

Code: [Select]

int analogIntervalPin = A2;
int activateIntervalPotPin = 1;
int ledPin = 0;

void setup() {
  // declare the ledPin as an OUTPUT:
  pinMode(activateIntervalPotPin, OUTPUT);   
  pinMode(ledPin, OUTPUT);

void loop() {
  digitalWrite(activateIntervalPotPin, HIGH); 
  int value = analogRead(analogIntervalPin);   
  digitalWrite(activateIntervalPotPin, LOW);     
  int convert = map(value, 0, 1024, 0, 10);


void blinkForReadValue(int readValue) {
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin, LOW);

    for(int i = 0; i < readValue; i++) {
      digitalWrite(ledPin, HIGH);
      digitalWrite(ledPin, LOW);


Thanks for your help!


I've resolved my issue.

Apparently the problem come from the library I've download to program the ATtiny85 from https://github.com/damellis/attiny/archive/master.zip

If you get into the same kind of problem just download latest version from:

That thing is wonderfull my analog read work as expected now!


Appart from getting instructions on how to program an Attiny85 you should also burn the bootloader into the Attiny85 itself. Burning the bootloader would make your Attiny more compatible with Arduino IDE sketches. To burn it, first setup everything you do when you programm the attiny, but instead of uploading a sketch go to Tools > Burn Bootloader don't forget to seect the right port int Tools > Board menu. After that is accomplished you could now program the Attiny85 again and hopefully your analog reading will be good.

Hope this helps.

Go Up