Author Options:

attiny85 problems Answered

OK so I recently discovered the ATTiny85 microcontroller and have though of many ways to use it.  After figuring out how to program it, I began testing its limits.  The pins I have been able to use so far are; VCC+GND (obviously), Reset, PWM 0+1, and A1.  A2+A2 however, I have not been able to use as analog input.  Does anyone know why?  I am using a Mac and arduino uno as ISP if that makes any difference.  Any help would be greatly appreciated.  P.S.  I'm pretty new to this, so please use simple language :)



3 years ago

Not enough info. What programming lang are you using? How are you physically (i.e., electrically) configuring the input pins? What are you measuring (what input voltage range)? Have you had success with analog input on A1?

Here is the code I used to test the analog pin 1 (pin 7);



int analogPin1 = 1;

int sensorPin = analogPin1; // select the input pin for the potentiometer

int ledPin = 0; // select the pin for the LED

int sensorValue = 0; // variable to store the value coming from the sensor

void setup() {

// declare the ledPin as an OUTPUT:

pinMode(ledPin, OUTPUT);


void loop() {

// read the value from the sensor:

sensorValue = analogRead(sensorPin);

// turn the ledPin on

digitalWrite(ledPin, HIGH);

// stop the program for <sensorValue> milliseconds:


// turn the ledPin off:

digitalWrite(ledPin, LOW);

// stop the program for for <sensorValue> milliseconds:



Below is the circuit I used to program the ATtiny85.

The programming lang (I assume that stands for language), I don't really know what I used. As for the test circuit, I have a potentiometer attached to 5v-A1-GND and an LED attached to pin 0-GND. This works just like it should, but when I try to change analog input pin 1 to analog input pin 2 or 3, it doesn't do anything. If you need any more info, I will try to provide it, but like I said I'm not very experienced with programming or Arduino.


Try setting A1 for INPUT with the pinMode() function...

A1 works perfectly for input already, the problem is that A2+A3 don't work for input, I will try setting A2 like you said and see what happens.

Look up any diagram of the attiny85 pinouts and assignments. The analog read pins are numbered different from the physical pin or digital read/write number(use 3 for physical chip pin 2, use 2 for physical chip pin 3, use 1 for physical pin 7) It is confusing. Other than that, unless you know what you are doing, the core may not support more than one analog input and what the chip is doing at the time, program and timer interrupts, clock speed, etc may affect the results of the analog to digital conversion. Since you have to rig up soft serial monitor to see what is going on in the chip and what values you are getting, it may look erratic.