I don't know if this belongs in this section but here goes.
I want to use the reset pin on ATtiny85 as, well, a reset pin while some process is going on. I thought it would be a simple matter of connecting a button switch to ground. Apparently it isn't.
I tested the function with a simple sketch at Wokwi, with both a Nano and an ATtiny85. It works with the Nano (resets in mid-process) but not with a Tiny85. The process starts with the designated button in both cases but doesn't reset with the Tiny85.
I even used the same pins on both platforms to make it easy to switch between the two.
Nano D3 -> Tiny85 PB3
Nano D4 -> Tiny85 PB4
Nano Reset -> Tiny85 RESET/PB5
What do I have to do to make it work?
int i;
void setup()
{
pinMode(3, INPUT_PULLUP); //starts process
pinMode(4, OUTPUT); //blinks LED
}
void loop()
{ //When pin3 is low, blink LED 10 times, twice per second.
if (digitalRead(3) == LOW)
{
for (i = 0; i <10; i++)
{
digitalWrite(4, HIGH);
delay(100);
digitalWrite(4, LOW);
delay(400);
}
}
}
It is, so something is wrong with the circuit. Please post a complete schematic diagram of the ATtiny85 board, with the switch (hand drawn is preferred).
Here it is. Not quite the hand-drawn one you asked for, but this should be clear enough. The schematic on the left was drawn with my CAD program and the one on the right is a screenshot of the simulation at Wokwi.
A pullup resistor on PB5/RESET is strongly recommended, and /RESET must be enabled in the fuse settings.
From the data sheet:
RESET: External Reset input is active low and enabled by unprogramming (“1”) the RSTDISBL Fuse. Pullup is activated and output driver and digital input are deactivated when the pin is used as the RESET pin.
Thanks. That's the kind of information I was looking for. I did a lot of searching before asking here but couldn't find a clear answer.
I read the datasheet but missed the "unprogramming" part. I'm quite experienced in general electronics but a total newbie with programming. At the moment I have no idea how to 'unprogram' something. I'll see if I can solve this on my own and ask in the forum if I can't.
You might try the search phrase "arduino attiny fuse settings" for information on how to set the fuses. The capability of changing the MCU fuses is built into the IDE, and into other programming software/hardware.
As you probably noticed, PB5 is not available if the pin is used for external reset.
I'll keep searching. It's quite frustrating that most of the hits seem to assume that the reset pin is already configured as an external reset pin and talk about ways to use it as an extra I/O pin.
Yes, that's the default, if you buy a bare attiny85 chip.
What you may have is a Digispark clone. A small board with an attiny85 on it. These come with the fuses already set to allow PB5 to be used as an I/o pin, and the Digispark bootloader installed, so it can be programmed over USB so that you don't need a separate AVR programmer.
If I'm right, changing the fuses may leave you unable to program the board over USB.
You don't need to change the fuses to achieve that. If you change your code so that it is non-blocking, you can read another pin while the process is going on.
I don't have any ATtiny85 chip with me, not yet. I was talking about the results of simulating it at Wokwi. I'm surprised that the folks at Wokwi would present an altered chip for general simulation.