thank you!!!!!!!!!!!!! both
the if == thing is a real smooth miss
I'm on it .. the way it is is interesting results
the more data I put in flash the -64 is getting bigger -58 after 8 x20x20
and I'll fix the code and see what happens
thanks again
thank you!!!!!!!!!!!!! both
the if == thing is a real smooth miss
I'm on it .. the way it is is interesting results
the more data I put in flash the -64 is getting bigger -58 after 8 x20x20
and I'll fix the code and see what happens
thanks again
zeroone = char(buffer[1]);
I agree, it looks wrong and its a lucky syntax error and/ but / because
Serial.print(zeroonetf); // is correctly changing betweeen 0 and 1
as
Serial.print(zeroone,DEC); // is changing from -64 to 0
when i change to what looks like the correct sysntax
zeroone = char(buffer[0]);
doesn't differentiate I'm always printing
Serial.print(zeroonetf); // = 1
even though
Serial.print(zeroone,DEC); // is changing from -64 to -128
You've made some changes to the code. You need to post the new code. There are still some things wrong, though.
zeroone = char(buffer[1]);
This MUST be 0 in the square brackets. Otherwise you are reading beyond the end of the array. You may also be writing beyond the end of the array, but I haven't verified that. buffer[ 0 ] is a char. There is no reason to cast a char to a char.
That is what I thought too..
zeroone = char(buffer[1]); // 0 or 1 neither gives me the 1's and 0' I put into the array
at least 1 gives me something I can test for at this size
and
PROGMEM prog_char mycharacter[3][3][3] =
// [9][20][20] still gives me the results I'm looking for.
// then with 4000 1's and0's
// at [10][20][20] still compiles and uploads but the output goes crazy
it's probably too much data to pass in a single command and I need 38x20x20
OK here is the simple code
// <ctrl><shift><m> serial monitor to view data
#include <avr/pgmspace.h> //allow arduino to store letter arrays in flash memory
int zeroonetf;
int myx;
int myy;
int myz;
char mystring[400];
char buffer[1];
char zeroone;
char izeroone;
int i=0;
PROGMEM prog_char mycharacter[3][3][3] =
{ //A
{{0,1,1,},
{0,0,0,},
{1,1,0,}},
//B
{{0,1,1,},
{0,0,1,},
{0,1,0,}},
//C
{{0,0,1,},
{0,1,0,},
{1,1,1,}}
};
void setup ()
{
Serial.begin(9600); // set up Serial library at 9600 bps
}
// i=0; see above
void loop()
{
for (myx = 0; myx < 3; myx++) {
for (myy = 0; myy < 3; myy++) {
for (myz = 0; myz < 3; myz++) {
// Necessary casts and dereferencing, just copy.
strcpy_P(buffer, (char*)pgm_read_byte_near(&(mycharacter[myx][myy][myz])));
zeroone = char(buffer[1]);
if (i==0)
{i=1;
izeroone==zeroone;}
if (izeroone == zeroone) {zeroonetf=1;}
else {zeroonetf=0;}
Serial.print(zeroone,DEC);
Serial.print(" ");
Serial.print(zeroone);
Serial.print(" ");
Serial.print(izeroone);
Serial.print(" ");
Serial.print(zeroonetf);
Serial.print(" ");
Serial.print(myx);
Serial.print(myy);
Serial.print(myz);
Serial.print(" ");
Serial.print(buffer);
Serial.print(" ");
Serial.print(buffer[1]);
Serial.print(" ");
Serial.println(buffer[0]);
delay(500);
}
}
}
}
zeroone = char(buffer[1]);
didn't you mean buffer[0] ?
array's in C/C++ start with index zero unlike e.g. some other languages
I didn't see how to copy from Serial Monitor
For future reference. Use the mouse and left button to select (or Ctrl and A for everything) then Ctrl and C to copy to the clipboard
char buffer[1];
There is NO reason to use a one element array. An array is simply the address of the first element in the array. Wherever you think you need a one element array, you can use a scalar variable, by passing the function the address of the variable (which is exactly what happens when you pass an array).
char crap;
strcpy_P(&crap, (char*)pgm_read_byte_near(&(mycharacter[myx][myy][myz])));
You are STILL using mycharacter (singular) as the name of a multi-dimensional array that holds a butt-load of values.
Just for giggles, instead of storing the output of pgm_read_byte_near() (which may not be the appropriate function for a large array - you may need to loose the _near part), in a variable, just print the value, between delimiters, with some identifier. Do you get the values you expect?