and fill it with 0s in the setup() function the arduino is frozen....
When I change the index 16 with 4 it works ...
What can i do to use a bigger array?
I dont think its the memory because its datatype is boolean which means that the whole array takes
16410*32= 20480 Bits or 2,56kByte
why does a boolean take a byte?
if a boolean takes a byte which datatype takes just a bit per value?
can i use and save such a big array or isnt it possible with the mega1280?
okay, so I have to write functions on my own where I kinda go through all adresses with a for loop beginning from the pointer of the array and get the values like this?
so i have to initialize an array with 2560 bytes so the memory is reserved.
then i intialize the pointer on this array.
mh...
yeah i try this now, it will also be a good exercise on pointers.
You don't really expect the pointer assignment and Serial.println() call to be performed, do you?
Where/how is pointer defined? Since pointer is not defined in the function, it hardly makes sense to return it.
While bytes and booleans are the same size, they are intended for completely different purposes. What you are returning from ReadValue() is NOT a boolean value.
Thank you all guys! i got it...
I didnt knew that a byte is something like : B00000000...
byte sequenzen[2560];
...
void setup() {
for (int i = 0; i < 2560; i++) {
sequenzen[i]=B00000000;
}
...
}
...
boolean ReadValue(int seq, int takt, int channel, int p) {
takt--;
int count = (seq*4*10*32)+(takt*10*32)+(channel*32)+p;
count--;
int x = count % 8;
int x2 = (count-x)/8;
return bitRead(sequenzen[x2],x);
}
void WriteValue(int seq, int takt, int channel, int p, boolean value) {
takt--;
int count = (seq*4*10*32)+(takt*10*32)+(channel*32)+p;
count--;
int x = count % 8;
int x2 = (count-x)/8;
bitRead(sequenzen[x2],x); ;
bitWrite(sequenzen[x2],x,value);
}
this works fine. Now its a pitty that this doesnt fit on the eprom, so i cannot save the sequenzes while the device is off...
oh i forgot to clear the function out of mistakes... i need two for several purposes for example copy and pasting sequences.
boolean ReadValue(int seq, int takt, int channel, int p, int Switch) {
takt--;
int count = (seq*4*10*32)+(takt*10*32)+(channel*32)+p;
int x = count % 8;
int x2 = (count-x)/8;
count=-1;
boolean BIT = bitRead(sequenzen[x2],x);
if (Switch) {
bitWrite(sequenzen[x2],x,inv(BIT));
} else {
return BIT;
}
}
void WriteValue(int seq, int takt, int channel, int p, boolean value) {
takt--;
int count = (seq*4*10*32)+(takt*10*32)+(channel*32)+p;
int x = count % 8;
int x2 = (count-x)/8;
count=-1;
bitWrite(sequenzen[x2],x,value);
}