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?
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!