loading

On occasion I have been using an Attiny13, 25, 45 or 85 in a project and just had that one pin short. These chips are supposed to have 6 I/O pins but pin number one (PB5/ADC0) doubles as RESET pin and in order to use it as an I/O pin, one needs to set the proper fuses in the chip. That is not so difficult but the problem is that once that fuse is set, the chip cannot be reprogrammed by SPI, but needs a High Voltage Programmer that first needs to reset the specific fuse bit again.

Sure you could upgrade to an Attiny2313, but often that means you need to install a new core, or making a new programming board, but that is a pain as well.

So, I was wondering if that RESET pin could be used as an I/O pin without messing with the fuse bits, after all, there still is a lot of Voltage to play with before you hit the reset level

Though it was a bit unclear to me what the required Low Voltage is that the Reset pin needs for a Reset, it seems that it is lower than what is generally interpreted as a ‘LOW’.

That potentially opens possibilities to use the range in between +Vcc and Vreset for input- analog as well as digital- without resetting the chip

I first tested the Analog input function as has a bigger range than the digital input funcion (as I expected the difference between LOW and RESET to be very small). I used an Attiny13, hooked up an LED and resistor to PB0 and connected the middle contact of a 25k variable resistor to Pin 1 and the outer contacts to Vcc and 0V respectively.

I then loaded the Attiny13 with the following program:

// Using the Reset pin as ADC0
const int Led = 0; 
int x=0; 
void setup() {
pinMode(Led, OUTPUT);
}
void loop() { 
digitalWrite(Led,HIGH);
x=analogRead(0); 
delay(x);
digitalWrite(Led,LOW); 
delay(x);
}

When the variable resistor is turned all the way up to the +Vcc rail, the LED flashes in a steady rhythm. When I turned down the variable resistor, the flashing frequency went up, i.e. a faster flashing LED.. as expected. This went on till the LED suddenly stopped flashing (as the RESET function kicked in). Ergo, there is a range in which pin 1 can be used for input, while still maintaining its RESET function.

It turns out that the point of reset was at 9K Ohm (out of 25). Which is equal to 5 *(9/25)= 45/25=9/5=2.2 Volt.

That is generally not much different from what is considered a LOW and it is a bit higher than what I understood the Vreset to be.

As ofcourse you cant have a circuit that is always on the brink of resetting, we need to build in some form of protection: something that keeps the voltage on pin 1 from hitting 2.2 Volt or lower.

Let’s consider the second circuit. Suppose that the lowest resistance of the LDR we measure under the light circumstances we are using it, is 1k. Then we know that the current through that 1 k must be minimally 2.2 mA to stay above the Reset voltage. Hence the total resistance of the LDR + the Resistor must be 5/2.2=2.27k, hence the resistor must be minimally 1.27k. The closest E12 values are 1.2 k and 1.5 k and we should choose 1.2k to be safe. (1.2k ->2.27 volt /1.5k -> 2 volt)

Ofcourse one can use the circuit with the resistor and LDR interchanged, but then it is much harder to calculate a safe resistor as in darkness the value of the LDR may go up to several Mega Ohm, calling for a resistor that is in that same range.

Should you want to use a trimpot on PB5 then you must connect one side to Vcc, the variable pin tp PB5 and the other side to ground via a resistor so the middle contact will never hit 2.2 Volts.
You can calculate the value of that resistor from the value of the variable resistor with the formula

r=0.58P
In which r is the value of the resistor and P the value of the potentiometer. So with a 10k potentiometer you need to use a 5.8k resistor. That will limit the reading range on the Analogue input, but at least you can use it as an analogue input.

Just a word of "caution" the resistor values I found were measured by a decent multi-meter but it isnt top notch. In 'your' case you may need a resistor that has a slightly different value and ofcourse it also depends on the variable resistor or other input source that you are using.

Given the fact that the Reset level is on 2.2 Volt, I have not bothered to try if it would work with digitalRead

About This Instructable

2,206views

15favorites

License:

Bio: I am a physician by trade. After a career in the pharmeceutical world I decided to take it a bit slower and do things I ... More »
More by diy_bloke:Working With the Funduino W5100 Ethernet Module. Uploading Data to ThingSpeak With MQTT Adding an MCP23017 I/O Extender to Arduino or ESP8266 
Add instructable to: