i am converting pixel array to String and send this String to arduino. but i Think this String is not converted properly because Serial.write send (8 bit or 8 character) i don’t know. and also want to send 100 character of string into Serial . please send your suggestion and getting help me out of this problem. for any mistake Sorry in advance.
for(int x =0 ; x < img.height; x++)
{
for(int y=0; y <img.width; y++)
{
int i = x+y*width;
if(img.pixels[i] == color(0,0,0))
{
i=1;
}
else
{
i=0;
}
String s = str(i);
print(s);
Serial.write(s);
delay(2);
}
}
and also tell me how to stop string after 100 character by not using ("\n" or "\r" )
It seems you are looking for the code below:
If you want to cluster your output in units the size of
img.width
you could do this:Please remember:
I have serious doubts about this calculation
int i = x+y*width;
as your data is probably structured as:Instead of: