Could not run the sketch (Target VM failed to initialize).

edited February 2017 in Arduino

Hello and good day, im trying to run sketch for a 3d cube but when i try to run the sketch i get the error " Could not run the sketch (Target VM failed to initialize) " here is the code and the port = new Serial(this,Serial.list()[1], 115200); code is highlighted, im not sure what went wrong.

import processing.serial.*;

Serial port;

int X;
int Y;
int Z;

float a;                          
float offset = PI/24.0;             
int num = 1;                     

boolean pink = true;

void setup() 
{ 
  size(800, 600, P3D);
  noStroke();  
  lights();


  println((Object[])Serial.list());
  port = new Serial(this,Serial.list()[1], 115200);
  port.clear();
} 


void draw() 
{     
  background(0, 0, 26);
  translate(width/2, height/2);

  while(port.available() == 0){
  }

  char reading = 0;

  while (reading != 'x') {
    while(port.available() == 0){
    }
    reading = (char)port.read();
  }
  X = port.read();
  while (reading != 'y') {
    while(port.available() == 0){
    }
    reading = (char)port.read();
  }
  Y = port.read();
  while (reading != 'z') {
    while(port.available() == 0){
    }
    reading = (char)port.read();
  }
  Z = port.read();

  {
    pushMatrix();
    stroke(0);
    rotateY((float)X/50.0);
    rotateX((float)Z/50.0);
    rotateZ((float)Y/50.0);
    scale(90);
    beginShape(QUADS);

    fill(0, 1, 1); 
    vertex(-1,  1,  1);
    fill(1, 1, 1); 
    vertex( 1,  1,  1);
    fill(1, 0, 1); 
    vertex( 1, -1,  1);
    fill(0, 0, 1); 
    vertex(-1, -1,  1);

    fill(1, 1, 1); 
    vertex( 1,  1,  1);
    fill(1, 1, 0); 
    vertex( 1,  1, -1);
    fill(1, 0, 0); 
    vertex( 1, -1, -1);
    fill(1, 0, 1); 
    vertex( 1, -1,  1);

    fill(1, 1, 0); 
    vertex( 1,  1, -1);
    fill(0, 1, 0); 
    vertex(-1,  1, -1);
    fill(0, 0, 0); 
    vertex(-1, -1, -1);
    fill(1, 0, 0); 
    vertex( 1, -1, -1);

    fill(0, 1, 0); 
    vertex(-1,  1, -1);
    fill(0, 1, 1); 
    vertex(-1,  1,  1);
    fill(0, 0, 1); 
    vertex(-1, -1,  1);
    fill(0, 0, 0); 
    vertex(-1, -1, -1);

    fill(0, 1, 0); 
    vertex(-1,  1, -1);
    fill(1, 1, 0); 
    vertex( 1,  1, -1);
    fill(1, 1, 1); 
    vertex( 1,  1,  1);
    fill(0, 1, 1); 
    vertex(-1,  1,  1);

    fill(0, 0, 0); 
    vertex(-1, -1, -1);
    fill(1, 0, 0); 
    vertex( 1, -1, -1);
    fill(1, 0, 1); 
    vertex( 1, -1,  1);
    fill(0, 0, 1); 
    vertex(-1, -1,  1);

    endShape();
    popMatrix();
  }
} 

Answers

Sign In or Register to comment.