We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi everyone, i have some questions about processing. when i tried to run it with arduino, i had somme problems like "Could not run the sketch" "Could not run the sketch (Target VM failed to initialize, for mor information, read revisions.txt and Help -> Troubleshooting.)"
The code : import processing.serial.*;
Serial myport; String portStream;
int B1in = 0; int B2in = 0;
void setup() {
size(500,500); background(255); stroke(160); fill(50); String portName = Serial.list()[2]; myport = new Serial(this, portName, 9600); myport.bufferUntil('\n'); }
void draw() { if(portStream != null) { if (portStream.length() == 6 && portStream.charAt(0) == 'S' && portStream.charAt(3) == '3') { B1in = int(portStream.substring(1,2)); B2in = int(portStream.substring(2,3));
if (B1in == 1) {
fill(0,255,0);
}
else {
fill(255,0,0);
}
rect(20,20,160,160);
if (B2in == 1) {
fill(0,255,0);
}
else {
fill(255,0,0);
}
rect(200,20,160,160);
} }
} void serialEvent(Serial myPort) { portStream = myPort.readString(); }
I am a beginner for using processing and arduino, Can anyone can tell me what's wrong with this problem ?
Thx !!!!!!
Answers
Please format your code. Edit your post, select your code and hit ctrl+o. Ensure there is a line above and below your code.
Kf
Can you run other examples? Your code seems ok.
Kf
We need to figure out if it is your code or processing? Can you run any other example? The one that comes with processing through the menu File>>Examples?
Also can you tell us your OS, Processing version?
Kf
https://forum.processing.org/two/discussion/20474/could-not-run-the-sketch-target-vm-failed-to-initialize-empty-sketch#latest
Kf
I've added a note to the FAQ here:
https://forum.processing.org/two/discussion/20562/could-not-run-the-sketch-target-vm-failed-to-initialize-errors-windows-nvidia
i found this code on the internet for testing my project with processing and arduino. I can run all exemples of processing, but it doesn't work with arduino.
Can you post the code that you are loading in your arduino?
Kf
attention in your sketch, "E" Arduino and "3" processing (?), I tried to send this by Arduino and your Processing sketch it seems to work
Thx, i have changed the code et it works, but i still dont have image, so strange
Your code is really hard to read. This is the main reason screenshots should not be used in a forum - referring to screenshots of code. This next tip might not solve your problem. Introduce a delay of 1 sec or so at the end of your setup in your Processing sketch.
Also, what do you get when you do the following change:
Kf
https://forum.Processing.org/two/discussion/16618/processing-with-arduino-void-serialevent#Item_1
How could you put code with the form 1,2,3,4... ? I have tried another code that my friend has already used, but it doesn't work either. it shows info like " [0] "COM7" _____NULL_______could not run the sketch (Target VM failed to initialize. For more information, read revisions, txt and Help ->Troubleshooting)
I try to put my code here:
}
Please format your code. Edit your post, select your code and hit ctrl+o. Ensure there is a line above and below your code.
Kf