Why do microcontrollers need a reset pin

Use the RESET PIN from Attiny85 as an input with a voltage divider

Bigjosh

Yes, you can use the analog-to-digital converter on pin 1, even if the external reset is still activated on this pin, as long as the voltage on this pin does not fall below the reset threshold.

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

simulate this circuit - scheme created with CircuitLab

...

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

Here is an Arduino test program that will light up the built-in LED when the button is pressed ...

Remarks:

A Trinket is basically just an ATTINY85 with a USB port and a pre-installed bootloader, so it's easy to type code into it using the Arduino IDE. Everything that is said here about the piece of jewelry applies to a bare ATTINY85 and vice versa.

The data sheet for the ATTINY85 specifies the minimum voltage at the reset pin, which as "1" is 0.9 volts * (V. IH2 ) is interpreted which corresponds to 4.5 volts. Since the ~ 4.54 volts output by the output divider is higher, it should be considered a "1" and not reset the chip.

There is 30k-60k built-in pullup on the reset pin so basically we could just use a 30k ohm R2 and not need R1, but I found that toggling noise just with the internal pullup can give you false resets .

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

I chose 1000 as the threshold for the analogRead because it offers a lot of leeway for inaccuracies in the values ​​of the two resistors on either side. If the button is not pressed, the reset pin should be very close to Vcc, and therefore analogRead () should be very close to 1023. When the button is pressed, it will drop the voltage by R2 when it is reset, but exactly how much lower depends on the exact values ​​of R1 and R2 (the actual value of the resistors may vary significantly from their market value due to the tolerance) and the internal Pull-up I chose a higher value than just the midpoint.

cocco

I knew there was an easier way! .... thanks for your exact answer ... I tested it and it works perfectly! By the way, I use 10k resistors ....

ThatAintWorking

Is this better than using a 3v3 zener diode instead of R2? With the 1k resistor there is the reset pin 3V from my voltmeter.

Bigjosh

@ThatAintWorking I think a zener would work fine but is over killing. As long as the RESET pin is above 0.9 volts, the chip won't reset, and as long as you can see the voltage drop (whatever it is) on the analog input, everything is fine.

Unknown 123

Are you really sure about that? What I just read is the V.ichH.2 is 0.9 * VCC volts not 0.9 volts

Bigjosh

@ Unknown123 You are absolutely right! Thanks for the correction. I updated the value of R2 and some calculations to reflect this. Thanks again!