# memory limit attiny 45

**URL:** <https://forum.arduino.cc/t/memory-limit-attiny-45/271105>\
**Category:** 3rd Party Boards\
**Created:** [November 21, 2014, 2:42pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105 "2014-11-21T14:42:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![KingBee](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@KingBee](https://forum.arduino.cc/u/KingBee)\
**Post date:** [November 21, 2014, 2:42pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/1 "2014-11-21T14:42:51Z")

</div>

Hi All,

I'm working on a 4x4 led array driven by a attiny 45.  
I seem to run into some memory issues.

I've defined a multidimensional array "scroll\_text" wich holds the data to scroll over the 4x4 screen.  
All seems to be working fine if i keep the size of this array below [4][19], a larger array results in a blank screen. The size of the compiled script is about 1550 bytes, which i think is well below the 4096 (??) limit of the attiny45.

(if i run the same script on my uno it CAN handle a larger arra)

Where am i gooing wrong?

[test7tiny.ino](https://forum.arduino.cc/uploads/short-url/b5NS2gD4gm4VQvMH0YHkHjWlYS7.ino) (4.34 KB)

---

<div class="post-metadata">

**Author:** ![dannable](https://avatars.discourse-cdn.com/v4/letter/d/76d3ee/32.png) [@dannable](https://forum.arduino.cc/u/dannable)\
**Post date:** [November 21, 2014, 2:54pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/2 "2014-11-21T14:54:43Z")

</div>

The Tiny45 only has 256 bytes of ram.

---

<div class="post-metadata">

**Author:** ![Hackscribble](https://avatars.discourse-cdn.com/v4/letter/h/a183cd/32.png) [@Hackscribble](https://forum.arduino.cc/u/Hackscribble)\
**Post date:** [November 21, 2014, 2:55pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/3 "2014-11-21T14:55:37Z")

</div>

Hi KingBee

You are running out of SRAM rather than Flash (program) memory. The ATtiny45 has 256 bytes of SRAM.

More information here: [Arduino Memories | Memories of an Arduino | Adafruit Learning System](https://learn.adafruit.com/memories-of-an-arduino/arduino-memories)

Regards

Ray

---

<div class="post-metadata">

**Author:** ![KingBee](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@KingBee](https://forum.arduino.cc/u/KingBee)\
**Post date:** [November 21, 2014, 3:03pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/4 "2014-11-21T15:03:27Z")

</div>

Thanks for the replies.

I must admit im not really sure what mem I use.  
after compiling and uploading with my arduino uno i get the message:  
1.514 bytes (of 4.096-byte maximum)

---

<div class="post-metadata">

**Author:** ![KingBee](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@KingBee](https://forum.arduino.cc/u/KingBee)\
**Post date:** [November 21, 2014, 3:04pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/5 "2014-11-21T15:04:50Z")

</div>

Ok, had to read it twice to get it apperently.  
So the data I use for variables is to large..  
Is there a work around for that?

---

<div class="post-metadata">

**Author:** ![Hackscribble](https://avatars.discourse-cdn.com/v4/letter/h/a183cd/32.png) [@Hackscribble](https://forum.arduino.cc/u/Hackscribble)\
**Post date:** [November 21, 2014, 3:15pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/6 "2014-11-21T15:15:15Z")

</div>

Is the array going to be used to store constant data (i.e. defined at compile time) which you are only going to read? Or is it going to be updated while the program is running?

If it is the former, then there is a way to hold the array in Flash memory and functions to read out the data when you need it.

Take a look here: [Gammon Forum : Electronics : Microprocessors : Putting constant data into program memory (PROGMEM)](http://www.gammon.com.au/forum/?id=12615)

---

<div class="post-metadata">

**Author:** ![KingBee](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@KingBee](https://forum.arduino.cc/u/KingBee)\
**Post date:** [November 21, 2014, 3:23pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/7 "2014-11-21T15:23:41Z")

</div>

It is indeed going to store constant data, i'll have a look at the link.  
Thanks

---

<div class="post-metadata">

**Author:** ![KingBee](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@KingBee](https://forum.arduino.cc/u/KingBee)\
**Post date:** [November 22, 2014, 4:35pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/8 "2014-11-22T16:35:33Z")

</div>

I'm not really understandig how to implement the trick from gammon;

I've made a simple script that (should) store a large array in PROGMEM, and then print each component of it.  
As far as i can see it does store the array in PROGMEM as the memory RAM usage is low (only couple of bytes extra).  
Only the values that are printed are in the range 100~800, instead of 1's and 0's.

I did get a message "invalid conversion from 'const int\*' to int; I therefore added the "int" in line:

> value = int(scroll\_text[j]_);_  
> _[/quote]_  
> _apperently there is a type mixup that I don't understand, can annyone assist?_  
> _Thanks,_  
> _[sketch\_nov21a.ino](https://forum.arduino.cc/uploads/short-url/eIBtHTVhqSAnvg5To6sTL4kbBaw.ino) (1000 Bytes)_

---

<div class="post-metadata">

**Author:** ![Hackscribble](https://avatars.discourse-cdn.com/v4/letter/h/a183cd/32.png) [@Hackscribble](https://forum.arduino.cc/u/Hackscribble)\
**Post date:** [November 23, 2014, 11:04am UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/9 "2014-11-23T11:04:56Z")

</div>

If your array is only going to store 0 or 1, change the declaration to:

```cpp
const byte scroll_text[4][64] PROGMEM = {
etc

```

Then to access the elements, try this:

```cpp
byte value = 0;
...
value = pgm_read_byte(&(scroll_text[j][i]));

```

---

<div class="post-metadata">

**Author:** ![KingBee](https://avatars.discourse-cdn.com/v4/letter/k/71e660/32.png) [@KingBee](https://forum.arduino.cc/u/KingBee)\
**Post date:** [November 23, 2014, 11:28am UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/10 "2014-11-23T11:28:11Z")

</div>

Tanks, it works!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 6, 2021, 4:57pm UTC](https://forum.arduino.cc/t/memory-limit-attiny-45/271105/11 "2021-05-06T16:57:34Z")

</div>

Closed on May 6, 2021, 4:57pm UTC


