i am printing an image of binary and i want to print exactly this Image of String in .txt file.
is this possible to take ouput of console print data to save as .txt file
Hi,
I can see that you already have created a writer that you called output.
So now, you just need to replace your print and println statements by output.print and output.println
Missing line break at the end of each line
Try to print ”\n“ at the end of each line
yes i did that . but i get same value and characters are changed .
Or use println instead of print
Please show your code
import processing.serial.*;
Serial myPort;
PImage img;
PrintWriter output;
String s;
int i,j;
void setup()
{
img = loadImage("vl.png");
size(100,100);
//loadPixels();
img.loadPixels();
output = createWriter("danish.txt");
myPort = new Serial(this, "COM6",115200);
noLoop();
}
void draw()
{
function();
}
void function()
{
for (int y=0; y<img.height; y++)
{
for (int x=0; x<img.width; x++)
{
int i= x+y*width;
//String s = str(i);
if ((i+1)%100 == 1) {
print("\n");
}
//int c = s.charAt(0);
//print(c);
if (img.pixels[i] == color(0,0,0))
{
i=1;
} else
{
i=0;
}
String s = str(i);
String[] q = splitTokens(s,"");
String[] d = sort(q,q.length);
for(j=0;j<q.length;j++)
{
print(q[j]);
output.print(q[j]);
myPort.write(q[j]);
delay(2);
}
}
}
}
You missed an output.print("/n") line13 of your function called function.
Also please correctly format you code using ctrl+t on processing before posting it here.
In notepad:
Is the display of line breaks activated?
See menu View
Or try to look at your file with another program like WordPad or MS Word
till not working.
ok leave it and help me in another way
i want to create image like in my above code console window. example(apple image in binary)
this image is printing in console and when i want each row of this image sending to arduino but my string array is printing just like another example . tell me what is mistake in my code
Show your code please
Are you using some kind of LED grid? Which form?
Are you using appropriate current limiting resistors?
An LED exploded in one of our labs at work with low voltages (5V); it can happen.
Always wear safety glasses when working on projects like this.
Hello,
Typo there…
output.print("/n") will print /n
There are the different possible outputs I used testing:
//Text file: // Output:
//output.print("\r"); // CR
//output.write("\r"); // CR
//output.print("\n"); // LF
//output.write("\n"); // LF
//output.write("\r\n"); // CRLF
//output.print("\r\n"); // CRLF
//output.print(); // Error! Won't run.
//output.println(); // CRLF
//output.print(""); // no output!
//output.write(""); // no ouput!
//output.print("/n"); // /n
//output.print(":)"); // :)
I used Notepad++:
https://notepad-plus-plus.org/
and select “View > Show Symbol > Show all Characters” to see the LF and CR characters (otherwise hidden from view).