Hi, i am just wondering how to disable the reset pin on the attiny85 as i need to use it as a analog input without it resetting.
I am not bothered about reprogramming the chip after i have got my sketch on it and the reset pin is disabled
const int Gin = A0; //Green sensor in
const int G = 4; //Green LED out
int Gsensor = 0; //Green sensor value
int Gvalue = 0; //Green remapped value
const int Rin = A3; //Red sensor in
const int R = 0; //Red LED out
int Rsensor = 0; //Red sensor value
int Rvalue = 0; //Red remapped value
const int Bin = A1; //Blue sensor in
const int B = 1; //Blue LED out
int Bsensor = 0; //Blue sensor value
int Bvalue = 0; //Blue remapped value
void setup() {
pinMode(G, OUTPUT);
pinMode(R, OUTPUT);
pinMode(B, OUTPUT);
}
void loop() {
Gsensor = analogRead(Gin);
Gvalue = map(Gsensor, 0, 1023, 0, 255);
analogWrite(G, Gvalue);
Bsensor = analogRead(Bin);
Bvalue = map(Bsensor, 0, 1023, 0, 255);
analogWrite(B, Bvalue);
Rsensor = analogRead(Rin);
Rvalue = map(Rsensor, 0, 1023, 0, 255);
analogWrite(R, Rvalue);
}
That is my code for the project as you can see i need to use all of the available I/O port for it to work unless there is another option
I have tried to gogle it but was just wondering if there was anyway to upload the sketch and then disable the reset pin or if the high voltage programmer is needed no matter what
You could , I guess just use two leds instead of three and flash them for the third state, or do a two to four decoder on two outputs .
That frees up a digital
Pin ( not sure if you can then use it as an analog; but you could use it to switch two inputs).
Instead of disabling the reset, you can use the part of the analog range that is above the voltage that will cause a reset (which is about 0.3 times Vcc.) Do this with a voltage divider, so that the minimum voltage you try to read is above the reset limit:
Here is what I have used in a windows command tool to disable the reset pin of an ATtiny85. You'll have to adapt it for your environment. The pin can then be used as analog ADC0.
To undo it all and make the chip programmable again, use a high voltage programmer (as already said).
I once, incidentally, built a special programmer including a high voltage programmer, so I could rapidly go through a development cycle including restoring the fuses to factory, reloading a sketch, disabling reset and testing. However, I came to the conclusion that it is not worth the effort of saving one pin unless you are designing a mass market product with a large production run. It is simply better to use a chip with more pins eg ATtiny 84 (which, incidentally, has a better ADC that the ATtiny85)