Pages: [1]   Go Down
Author Topic: How to use the ATtiny85 reset as an analog input?  (Read 898 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is no need for the reset on this particular application as it's achieved by different means but it would be nice to have it around just in case I need to re-program it in the future without a high voltage set-up.

I'd like to use it as an analog input for a switch. From what I've read and been told it must not drop below a certain voltage. Firstly, is that statement true? If so, what is that voltage? I'm confused as to what the data sheet is actually defining.

Secondly, how on earth would I connect one up and what would it look like in the sketch? Would it just be like any other switch? I assume if it were to input at 0 @ 0v (open) it wouldn't even reset? And if it were to switch and send input value 1 (or 255) @ 5V it would be fine?
Logged

UK
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Once you disable the reset pin it behaves like any of the other pins.

Getting an analog reading from reset pin (ADC0) would look like
Code:
int reading = analogRead(0);

Where abouts in the datasheet does it say about not dropping below a certain voltage?

If you're connecting a switch why do you need analogRead()? Why not digitalRead()?
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8976
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

One problem you might not have anticipated is that once you disable the reset signal you can no longer use serial programming.  You might want to invest in a High Voltage Rescue Shield which will allow you to reset the fuses using high voltage parallel programming: http://mightyohm.com/blog/products/hv-rescue-shield-2-x/
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Denmark
Offline Offline
Edison Member
*
Karma: 37
Posts: 1096
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Just did a small experiment:

I connected a potmeter to reset pin, and slowly lowered the voltage.
Below is the result.

Readings from 1023 to 455, which means that below 5V * 455/1023 = 2.22V the Tiny will reset.

Code:
Test A0 1023
Test A0 1023
Test A0 1010
Test A0 973
Test A0 955
Test A0 948
Test A0 924
Test A0 907
Test A0 896
Test A0 878
Test A0 870
Test A0 832
Test A0 800
Test A0 768
Test A0 750
Test A0 720
Test A0 669
Test A0 650
Test A0 635
Test A0 609
Test A0 568
Test A0 520
Test A0 488
Test A0 455 -<---resetting
Test A0 455
Test A0 458
Test A0 469
Test A0 464
Test A0 466
Test A0 467
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Perfect Erni! I'll give it a shot with a switch tomorrow and post the results.
Logged

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5761
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'd like to use it as an analog input for a switch. From what I've read and been told it must not drop below a certain voltage. Firstly, is that statement true?

Yes.

If so, what is that voltage? I'm confused as to what the data sheet is actually defining.

Look in the section "Electrical characteristics->DC Characteristics" on the datasheet. It's about 0.3V, depending on your Vcc.

Secondly, how on earth would I connect one up and what would it look like in the sketch? Would it just be like any other switch? I assume if it were to input at 0 @ 0v (open) it wouldn't even reset? And if it were to switch and send input value 1 (or 255) @ 5V it would be fine?

The reset pin internal pullup is about 45kOhms (it's in the same section of the datasheet). If you add an external pull-down resistor of double that, the voltage on the pin will be at about 3.33V (assuming you're using 5V). Use your switch to connect the pin to the 5V line when you press it. Measure the voltages using analogRead().
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Pages: [1]   Go Up
Jump to: