Pages: [1]   Go Down
Author Topic: ATtiny85 20PU analogread  (Read 553 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
http://hlt.media.mit.edu/?p=1695

I'm using my Arduino 1.0 to program the ATtiny:
http://hlt.media.mit.edu/?p=1706

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:
int analogIntervalPin = A2;
int activateIntervalPotPin = 1;
int ledPin = 0;

void setup() {
  // declare the ledPin as an OUTPUT:
  //Serial.begin(9600);
  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);

  blinkForReadValue(convert); 
 
  delay(2000);
 
}

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

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

    delay(500);                     
}

Thanks for your help!
« Last Edit: March 17, 2013, 09:01:24 pm by jobard » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
http://code.google.com/p/arduino-tiny/downloads/detail?name=arduino-tiny-0100-0015.zip

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

Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Arduino Uno R3
Mac OSX Lion


Pages: [1]   Go Up
Jump to: