Browse files

Processing sketch to import text, send over serial

Processing sketch to import a text file, read in one line at a time, and
send it over the serial connection to a Tiny CNC drawing robot.
  • Loading branch information...
MakerBlock committed Jan 2, 2014
1 parent 65f0a6e commit 32b8fc7b46274bc969742e9cf8d21f7c6403db2b
Showing with 8,534 additions and 0 deletions.
  1. +64 −0 SendingSerial003.pde
  2. +8,470 −0 file.gcode
@@ -0,0 +1,64 @@
* Simple Write.
* Check if the mouse is over a rectangle and writes the status to the serial port.
* This example works with the Wiring / Arduino program that follows below.
import processing.serial.*;
// import;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
String command;
void setup()
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 115200);
void readData(String myGcodeFile)
File file=new File(myGcodeFile);
BufferedReader br=null;
br=new BufferedReader(new FileReader(file));
String text=null;
/* keep reading each line until you get to the end of the file */
/* Spilt each line up into bits and pieces using a comma as a separator */
print(text + '\n');
}catch(FileNotFoundException e){
}catch(IOException e){
try {
if (br != null){
} catch (IOException e) {
void importTextFile(){
String[] strLines = loadStrings("file.gcode"); // the name and extension of the file to import!
for(int i = 0; i < strLines.length; ++i){
String[] arrTokens = split(strLines[i], ','); // use the split array with character to isolate each component
float xx = float(arrTokens[0]); // cast string value to a float values!
float yy = float(arrTokens[1]); // cast string value to a float values!
float zz = float(arrTokens[2]); // cast string value to a float values!
// pointList.add( new PVector(xx,yy,zz) ); // add values to a new array slot
Oops, something went wrong.

0 comments on commit 32b8fc7

Please sign in to comment.