From 383de86ae83a0166608f42f1c760bf41a0002989 Mon Sep 17 00:00:00 2001
From: cs141016 <cs141016@uniwa.gr>
Date: Wed, 11 Dec 2019 11:54:43 +0000
Subject: [PATCH] Upload files to ''

---
 sketch_3d_model.pde | 48 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 sketch_3d_model.pde

diff --git a/sketch_3d_model.pde b/sketch_3d_model.pde
new file mode 100644
index 0000000..17704e1
--- /dev/null
+++ b/sketch_3d_model.pde
@@ -0,0 +1,48 @@
+import processing.serial.*;
+String row;
+int xpin;
+int ypin;
+int zpin;
+Serial myPort;
+
+void setup(){
+  String portName = Serial.list()[0]; //open COM4 port
+  myPort = new Serial(this, portName, 9600);
+   
+  size(640,360,P3D);
+  background(0);
+  lights();
+  
+  pushMatrix();
+  translate(130, height/2, 0);
+  rotateY(1.25);
+  rotateX(-0.4);
+  noStroke();
+  box(100);
+  popMatrix();
+  
+  pushMatrix();
+  translate(500, height*0.35, -200);
+  noFill();
+  stroke(255);
+  sphere(280);
+  popMatrix();
+
+}
+
+void draw(){
+
+  if ( myPort.available() > 0){  // If data is available,
+    
+    row = myPort.readStringUntil('\n'); // read it and store it in variable
+    if (row != null){
+      String splittedRow[] = split(row, '\t');
+      if (splittedRow.length > 0){xpin = Integer.parseInt(splittedRow[0].trim());}         
+      if (splittedRow.length > 1){ypin = Integer.parseInt(splittedRow[1].trim());}        
+      if (splittedRow.length > 2){zpin = Integer.parseInt(splittedRow[2].trim());} 
+    
+      println(xpin + ", " + ypin + ", " + zpin); //print it out in the console
+    }
+  } 
+  
+}