Use Attiny85 reset pin as input (switch)

You my try the following approcah (I will try after this posting):

In order to upload sketch into ATtiny85 using Arduiono as ISP (Programmer), the RSTDISBL fuse bit must be in unprogrammed state (means: Pin-1 is a RESET/-pin).

You upload a sketch in which Pin-1 has been considered as an output line to blink a LED.

Now, use a AVR Programmer to program the RSTDISBL fuse bit (Pin-1 will work as IO line). You cannot change the fuse bits using Arduino as ISP Programmer.

Put the ATtiny on a breadboard, connect a LED at Pin-1 with a series resistor. Connect power supply and GND. Check if LED is blinking or not.

(Note: If you own a AVR Programmer, then their is no need to use Arduino as ISP (Programmer)).

I have performed my experimnet of post #22 and it is working.

Now, I cannot use the AVR Programmer to unprogram the RSTDISBL fuse bit as Pin-1 is no more available as RESET-pin which is necessary for ISP Protocol to work!

I have lost my one expensive ATtiny85!

Never mind!! The experiment helped me to learn!!!

Is there any way to recover the RESET-pin by unprogramming the RSTDISBL fuse bit?

Yes. You need to build a HV programmer that you can use with your Uno. But I think you knew that already.

This is the one I built (picture)

1 Like

Yes, i forget the resistor on the base of transistor, i will add it

So sorry for this
Here is a very useful video explain how to make a (simple and low cost) high voltage avr programmer to reback you attiny alive

Hope this success for you

1 Like

How do i define reset pin in the sketch in my old sketch it was A0

Should i define it now as 5

#define red   9
#define lipo  A0
 
float lipoV = 0;

 
void setup() {
 
pinMode(red,OUTPUT);
pinMode(lipo,INPUT);


}
 
void loop() {
 
lipoV = analogRead(lipo);
 
if(lipoV<700){
  digitalWrite(red,HIGH);
}

else {
  digitalWrite(red, LOW);
}

}

Change #define lipo A0 to #define lipo 5?

When using Attinycore the reset pin is A0

So, the proposal to use RESET (A0) as IO looks like this:
image

And you use analogRead() to read the switch value. When the IO switch is not pressed, the pullup keeps the voltage at VCC (reads ~1023) and the device does not reset.
When you press IO, the pin voltage should be dropped by the voltage divider created, and analogRead() should read about 0.75*VCC (768), which is easily noticed, but not low enough to reset the chip.
When you press the RESET button, the signal is hard connected to GND, and the chip resets. (assuming that RESET is enabled.)

2 Likes

You can use pin reset as A0 (analog input)if you simply provided it with voltage above 2.5v as hmeijdam said

The reset will be provided with lipo 3.7v to read its voltage so will will always above 2.5v

By fuse bit, Pin-1 of ATtiny85 has been configured to work as RESET pin; now, will Pin-1 be working as an analog channel (ADC0) for the internal ADC?

Yes, that's what I demonstrated in my sketch in post #10

ADC0 (PB5) is actually the default value of the ADC. See datasheet.

1. Pin1-1 of ATtiny85 is attached with five different signals (Fig-1).


Figure-1:

2. I undestand from the following excerpt (Fig-2) of data sheets that when one signal is activated, then the othet four signals should remain deactivated.


Figure-2:

3. The diagram of Fig-3 is my conceptual undertanding for Step-2; where, Pin-1 has been configured to work as RESET-pin.


Figure-3:

4. In your post #10, you have used Pin-1 as RESET pin and at the same time, you have used ADC0 channel to acquire analog signal of Pin-1 (Fig-4). The simultaneous use of two signals (RESET and ADC0) are not recommended by data sheets; but, you have done so in a cleverly way to meet your requirements. (I need to install R1 to see that at about 2.1V at RESET-pin, the MCU gets resetted; as a result, the ADC measurement range that I have got is: 2.2V to 2.7V.)


Figure-4:

5. My next attempt is to measure the ADC0's voltage (range: 2.2V - 2.7V) and show it on I2CLCD or TM1637-based 7-seg Display Unit to see (for myself) that RESET-pin and ADC0 are working simultaneously. For my experiment, I am using Digispark ATtiny85 Dev Board.

6. My query is: why have you used controversial ADC0 channel (limited range) in the sketch of your post #10 when there are few full range ADC channels are available?

I did not need the full 10 bit (1024) resolution.

This will print you the full 10 bit resolution of the reset pin.
PB0 is TX

void setup() {
  ADCSRA = _BV(ADEN) | _BV(ADSC) | _BV(ADATE) | _BV(ADPS2);  // Enable ADC in free running mode.
  Serial.begin(9600);// prints on PB0 as TX
}

void loop() {
  Serial.println(ADC);
  delay(500);
}

Does the above line mean that if I include it in my sketch, then the ATtiny85 will be transmitting asynchronous TTL signal on PB0-pin at Bd = 9600?

If using Attinycore indeed. That has a built in softwareserial protocol called Serial.

I have become interested on the following feature (Fig-1) of the USI Port of ATtiny85. Unfortunately, I don't find any description in data sheets on how to configure the USI Port to work as Asynchronous Port.


Figure-1:

The USI is designed for supporting SPI and TWI (I2C) communication.
I have never seen it used for asynchronous serial, which does not mean it can't be used/done.

Better buy a Attiny with a UART, if you want to play with serial. Attiny2313/4313 have one and also a nice 16 Bit timer. I know they are stone-age, but I learned a lot by playing with them.

Can't compare with the modern Attinies though.

[edit] found a blog that tells USI serial read is possible
[edit2] And after a little more google USI serial send

1 Like

Thank you so much for guiding me to realize he UART implementation in ATtiny85. Having read the referenced documents, it is my understanding that the implemetation would be time consuming; moreover, the system clock of Digispark Board is also inaccurate (16.5 MHz).

So, for the time being, I am not working on it.

I am hooking up I2CLCD with the I2C Bus of the ATtiny85 of the Digispark Boad to monitor the value of ADC0 of Fig-4 of post #34.

If there is a voltage drop at the vcc (5v) of the attiny85, the reset pin wont work as analog pin?

I have a voltage at the vcc (4.66v) it is working ok and the led of battery indicator turn on but when the voltage go below 4.66v (same battery connected) the led do not turn on

It is because the vcc voltage drop?

#define red   9
#define lipo  A0
 
float lipoV = 0;

 
void setup() {
 
pinMode(red,OUTPUT);
pinMode(lipo,INPUT);


}
 
void loop() {
 
lipoV = analogRead(lipo);
 
if(lipoV<700){
  digitalWrite(red,HIGH);
}

else {
  digitalWrite(red, LOW);
}

}

Think about that if your VCC drops from 5V to 3,7 Volt and your Lipo stays at 3,7 Volt your analog reading will be 1023, which is higher than 700.

The lower your VCC, the more you will need to increase the 700 towards the 1023 maximum. Try it with <800 and see what happens.

This is a result of the fact that you are measuring the difference between VCC and your lipo. You are not measuring an absolute voltage. That difference is becoming smaller when VCC drops.