Voltage divider & pull-up with analogRead

The Attiny has 6 pins that you can use as I/O.

While 5 of them are really easy to use the Pin 1, the Reset PIN , obviously Resets the Microcontroller if the voltage is lower than around 2.5v.

By reprogramming the fuses to use the reset pin as an I/O pin i'm not able anymore to use the arduino ISP Programmer.

So the only way to use it as input, without resetting the MC, is to stay over 3v and use analogRead?

After i finally got that, i played around a little with my multimeter (only measuring tool aviable) and experimented with resistors.


simulate this circuit – Schematic created using CircuitLab

The powersupply(battery) outputs around 5.11v.

not pressed i get 5.11v on the "reset pin".
pressed i get 3.41v on the "reset pin".

not pressed the resistace is 39K Ω.
pressed the resistace is 19K Ω.

Now, as i don't want to reprogramm the fuses or burn the Attiny85 my question is:

Can i harm somehow the attiny using this circuit with analogRead(); ?

Readings would be around 680 when pressed or 1000 when not pressed.

Should i use other resistors to consume less current/send to much current continuously ? ... if this works...

Any other suggestions?


enter image description here

I use pins 2(PB3),3(PB4),5(PB0),6(PB1) as PWM channels (with npn transistors); Red,Green,Blue,white.

Used pin 7(PB2) as button.but i need also a Potentiometer...


pin 7(PB2) becomes Potentiometer (analogRead).

and , i hope

pin 1(PB5) becomes a button using analogRead or whatever.


this site explains more about the problem, although i need a simple button.



I did not test the circuit above. I'm asking you if it could work , if there is something wrong. I have fear to damage the pin.

All i know is that:

  1. it resets with low voltage using normal potentiometer setup or normal button setup
  2. if i set the fuses i'm not able to reprogramm the chip

  3. pin1 = pb5 = adc0 = analogread(A0) = Arduino pin5 = RESET

  • \$\begingroup\$ I am sorry, but I dont quite understand what the problem is. Once reset is set as I/O pin, the MCU wont be able to reset anymore. You can provide less than 2.5V to it. \$\endgroup\$
    – Golaž
    Oct 13, 2015 at 19:45
  • \$\begingroup\$ Once reset is set as I/O pin you are not able to reprogram it as the reset is needed with ISP \$\endgroup\$
    – cocco
    Oct 13, 2015 at 19:46
  • \$\begingroup\$ Yes. So you want to reprogram it? \$\endgroup\$
    – Golaž
    Oct 13, 2015 at 19:49
  • \$\begingroup\$ maybe? if there is no need for another complex circuit. \$\endgroup\$
    – cocco
    Oct 13, 2015 at 19:50
  • \$\begingroup\$ You would need to make a HVSP (high-voltage serial programming) circuit: instructables.com/id/AVR-Attiny-fusebit-doctor-HVSP Its not really that complicated. \$\endgroup\$
    – Golaž
    Oct 13, 2015 at 19:53

1 Answer 1


Yes, you can use the analog to digital converter on pin 1 even if the external reset is still enabled on that pin as long as the voltage on that pin does not drop below the reset threshold.

Here is a simpler version of your circuit that works reliably...


simulate this circuit – Schematic created using CircuitLab


When the button SW1 is pressed, the resistors R2 and R1 form a voltage divider that puts about 4.54 volts onto pin RST.

Here is an Arduino test program that will light the onboard LED when ever the button is pressed...

int led = 1;    // Onboard led on trinket

setup() {
    pinMode( led, OUTPUT );

loop() {
    if (analogRead(0)) > 900 ) {   // reset pin is near Vcc
        digitalWrite( led , 0 );   // turn led off
    } else {                       // reset pin is less than 900/1024 * 5 vcc
        digitalWrite( led , 1 );   // turn led on


A Trinket is basically just an ATTINY85 that has a USB connector and a preloaded bootloader so it is easy to get code into it using the Arduino IDE. Everything said here about the Trinket goes for a bare ATTINY85 and vice versa.

The datasheet for the ATTINY85 specifies the minimum voltage on the Reset pin that will interpreted as "1" as 0.9 volts * (VIH2), which comes out to 4.5 volts. Since the ~4.54 volts output by out voltage divider is higer than that, it should be seen as a "1" and not reset the chip.

enter image description here

There is 30k-60k built in pullup on the reset pin, so we could in principal just use, say, a 30k ohm R2 and not need R1 but I've found that you can get spurious resets from switching noise with only the internal pullup.

I picked 10k & 1k ohm resistors because they are common and provide enough current reliably work, but only waste about 2mA when the button is pushed. Very little current is used when the button is not pressed.

I picked 1000 as the threshold value on the analogRead because it gives plenty of headroom on both side for inaccuracies in the values of the two resistors. When the button is not pushed, the reset pin should be very near Vcc and so the analogRead() should be very near 1023. When the button is pushed, the voltage on reset will be pulled lower by R2, but exactly how much lower depends on the exact values of R1 and R2 (resistors' actual value can be quite different from their market value due to tolerance) and the internal pull-up, so I picked a higher value than just the midpoint.

  • \$\begingroup\$ i knew there was a simpler way!.... thank you for your precise answer... i tested it and it works perfect! btw i'm using 10k resistors.... \$\endgroup\$
    – cocco
    Oct 14, 2015 at 9:23
  • \$\begingroup\$ Is this better than using a 3v3 zener diode instead of R2? With the 1k resistor, it gives the reset pin 3V by my voltmeter. \$\endgroup\$ Aug 12, 2017 at 21:56
  • \$\begingroup\$ @ThatAintWorking I think a zener would work fine, but is over kill. As long as the RESET pin is above 0.9 volts, the chip will not reset and as long as you can see the voltage drop (whatever it is) on the analog input, then everything is good. \$\endgroup\$
    – bigjosh
    Aug 13, 2017 at 3:10
  • \$\begingroup\$ Are you really sure about this? What I've just read is that \$VIH2\$ is 0.9*VCC Volt not 0.9 Volt \$\endgroup\$
    – Unknown123
    Mar 4, 2018 at 15:55
  • \$\begingroup\$ @Unknown123 You are absolutely right! Thank you for the correction. I've updated the value of R2 and a couple of the calculations to reflect this. Thanks again! \$\endgroup\$
    – bigjosh
    Mar 4, 2018 at 20:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.