Go Down

Topic: max length of arrray (Read 1 time) previous topic - next topic

cheesemunger

I need an array of 512 but i found this was imposible for my small brain, and after reading arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1227211052/14#14 (not allowed to link on first post soz) I found out the arduino does not have enough ram.
The array is for a DMX controller so must be 512 places of storage each holding up to the value 255. This means I can't use the work around on the other thread.

Can any of you clever people think of a work around or do I have to completely rethink my DMX design?

mem

If you are frugal with the rest of your variables, you can fit an array of 512 bytes in the Arduino ram.  Have upu tried?

cheesemunger

#2
Dec 16, 2008, 09:57 pm Last Edit: Dec 16, 2008, 09:57 pm by cheesemunger Reason: 1
yer that was the first thing i tried :( but I also need a buffer array of bout 50 so im stuck lol

mem

a buffer of 50 bytes plus the array is still only 562 bytes.

cheesemunger

oh mmmm and my array of 512 would be able to store up to 255 in every space? btw thanks for your amazingly quick reply

mem

yes, you can store 512 8 bit values (0-255) in 512 bytes.

cheesemunger

oh ok i dont know whats happening then???? id declare that like:

int myLights[512];

right?

halley

If you need to store 8bit values, make your array of bytes instead of ints.

Code: [Select]

byte myLights[512];


If you use an int for each element, it can store bigger numbers but takes two bytes PER ELEMENT, so that table you gave would take up 1024 bytes of memory.

cheesemunger

oh ok stupid me thanks for your help

patgadget

And if you don't need to modulate all the light you can let say:
have 25 DMX channel that have a 0-255 value and send all the rest to zero! they won't take any memory!

Patgadget
Montreal

Go Up