Attiny85 Toggle Modes with Power On

So I was wondering if there was a way to program an attiny85, with arduino bootloader, to cycle through modes with each power up. I was thinking that I could simply write a value to the eeprom and increment it each time the attiny is powered up. I am trying to get around using a button to change modes and using up an extra pin. Is there a better/ simpler way to do this or would the eeprom route be the best?

ookid: I was thinking that I could simply write a value to the eeprom and increment it each time the attiny is powered up. I am trying to get around using a button to change modes and using up an extra pin. Is there a better/ simpler way to do this or would the eeprom route be the best?

What eeprom? There is on-chip RAM where variables are kept, but there is no non-volatile memory available - it's all flash memory (not accessible outside of the programming/upload process.)

[quote author=Runaway Pancake link=topic=151751.msg1139623#msg1139623 date=1362229449] What eeprom? [/quote]

The ATtiny85 has got 512 bytes of EEPROM, hasn't it? I don't know whether it's accessible to the bootloader, but it's there.

? ? ? OP wants on-chip non-vol access from the sketch where each power cycle would increment/store a value in non-vol and thereby result a unique function.

[quote author=Runaway Pancake link=topic=151751.msg1139656#msg1139656 date=1362231916] ? ? ? OP wants on-chip non-vol access from the sketch where each power cycle would increment/store a value in non-vol and thereby result a unique function. [/quote]

The on chip EEPROM memory could be used for such. EEPROM is non-volatile, accessible by user's sketch code. What is the question?

Lefty

I thought its architecture was the same as the 328's. I must be wrong.

Anyway, I guess the OP would like some guidance, or a few lines of code, whereby he could write a value to an address.

[quote author=Runaway Pancake link=topic=151751.msg1139678#msg1139678 date=1362233433] I thought its architecture was the same as the 328's. [/quote]

The 328s have EEPROM too. It's a common feature of the Arduino platform. There's even a library to access it.

http://arduino.cc/en/Reference/EEPROM

Glory*!*

"... Woe is me! for I am undone..."

N.B. "The EEPROM memory has a specified life of 100,000 write/erase cycles, so you may need to be careful about how often you write to it."

[quote author=Runaway Pancake link=topic=151751.msg1139690#msg1139690 date=1362234075] Glory*!*

"... Woe is me! for I am undone..." [/quote]

No, not yet. You just have not spent enough time reading AVR datasheets. The memory types and capacity are usually listed on page one as 'bullet points". Flash, SRAM, and EEPROM memories, learn there purposes and useages.

Lefty

The example:
#include <EEPROM.h>
void setup()
{
for (int i = 0; i < 512; i++)
EEPROM.write(i, i);
}

So, it requires a library (EEPROM.h)?

No, a library just makes it easier to utilize, but it’s perfectly possible to read or write directly to eeprom memory in a user’s sketch if you know how to manipulate the hardware registers correctly that are associated with the EEPROM. Again the specific AVR datasheet has all the gory details.

Lefty

There are also Libc functions available... http://www.nongnu.org/avr-libc/user-manual/group__avr__eeprom.html

Wow, I honestly just remembered I posted this question, things have been crazy on my end. Anyway, thanks for all the help guys, I will go ahead and try implementing this with EEPROM then. I wasn't sure if the library was supported with the tiny core but I guess there is only one way to find out, just trying it! Have a wonderful day!