程序:
/*
* By Hannah Perner-Wilson, www.plusea.at
* Modified 3/30/2012 By Brian E Kaminski, www.AdvancerTechnologies.com
*
* IMPORTANT!!:
* Scroll down to set your serial port
* Scroll down to set your thresholds
*/
import processing.serial.*;
// definition of window size
// you can change the size of the window as you like
// the thresholdGraph will be scaled to fit
// the optimal size for the thresholdGraph is 1000 x 400
int xWidth = 1200;
int yHeight = 750;
// xPos input array, using prefix
int[] xPosArr= {0,0,0,0,0,0};
//
int[] messageArr= {0,0,0,0,0,0};
// Arrays for threshholding
int[] threshMax= {0,0,0,0,0,0};
int[] threshMin= {0,0,0,0,0,0};
// variables for serial connection. portname and baudrate are user specific
Serial port1;
//Set your serial port here (look at list printed when you run the application once)
String V3 = Serial.list()[1];
String portname1 = V3;
int baudrate = 9600;
int prefix = 10001;
boolean myCatch = false;
String serialIN = "";
String serialINPUT = "";
String buffer = "";
int value = 0;
// ThresholdGraph draws grid and poti states
ThresholdGraph in;
void setup(){
// set size and framerate
size(xWidth, yHeight);
frameRate(25);
background(255);
strokeWeight(5);
stroke(0);
smooth();
strokeCap(ROUND);
// establish serial port connection
port1 = new Serial(this, portname1, baudrate);
port1.bufferUntil('\n') ;
println(Serial.list()); // print serial list
// create DisplayItems object
in = new ThresholdGraph();
// THRESHOLD VALUES:
// using the thresholdGraph you can determine the MIN and MAX values
// of your sensors. Enter these here. They must lie between 0 and 1000.
//MIN trashhold
threshMin[0] = 20; // one
threshMin[1] = 20; // two
threshMin[2] = 20; // three
threshMin[3] = 20; // four
threshMin[4] = 20; // five
threshMin[5] = 20; // six
//MAX trashhold
threshMax[0] = 600; // one
threshMax[1] = 600; // two
threshMax[2] = 600; // three
threshMax[3] = 600; // four
threshMax[4] = 600; // five
threshMax[5] = 600; // six
}//end setup
// draw listens to serial port, draw
void draw(){
// listen to serial port and trigger serial event
while(port1.available() > 0){
serialIN = port1.readStringUntil('\n');
//println((int)float(serialIN));
if(serialIN != "")
serialEvent(serialIN);
else
println("found empty");
}
// threshold serial input
threshHolding();
// draw serial input
in.update();
}//end draw()
错误信息:
Arduino:1.6.0 (Windows 8), 板:"Arduino Uno"
AnalogVisualizationProcessing.pde:10:1: error: 'import' does not name a type
AnalogVisualizationProcessing.pde:20:4: error: expected unqualified-id before '[' token
AnalogVisualizationProcessing.pde:23:4: error: expected unqualified-id before '[' token
AnalogVisualizationProcessing.pde:26:4: error: expected unqualified-id before '[' token
AnalogVisualizationProcessing.pde:27:4: error: expected unqualified-id before '[' token
AnalogVisualizationProcessing.pde:30:1: error: 'Serial' does not name a type
AnalogVisualizationProcessing.pde:33:20: error: 'class HardwareSerial' has no member named 'list'
AnalogVisualizationProcessing.pde:45:1: error: 'ThresholdGraph' does not name a type
AnalogVisualizationProcessing.pde: In function 'void setup()':
AnalogVisualizationProcessing.pde:49:23: error: 'size' was not declared in this scope
AnalogVisualizationProcessing.pde:50:15: error: 'frameRate' was not declared in this scope
AnalogVisualizationProcessing.pde:51:17: error: 'background' was not declared in this scope
AnalogVisualizationProcessing.pde:52:17: error: 'strokeWeight' was not declared in this scope
AnalogVisualizationProcessing.pde:53:11: error: 'stroke' was not declared in this scope
AnalogVisualizationProcessing.pde:54:10: error: 'smooth' was not declared in this scope
AnalogVisualizationProcessing.pde:55:13: error: 'ROUND' was not declared in this scope
AnalogVisualizationProcessing.pde:55:18: error: 'strokeCap' was not declared in this scope
AnalogVisualizationProcessing.pde:58:3: error: 'port1' was not declared in this scope
AnalogVisualizationProcessing.pde:58:15: error: expected type-specifier before 'Serial'
AnalogVisualizationProcessing.pde:58:15: error: expected ';' before 'Serial'
AnalogVisualizationProcessing.pde:60:18: error: 'class HardwareSerial' has no member named 'list'
AnalogVisualizationProcessing.pde:60:24: error: 'println' was not declared in this scope
AnalogVisualizationProcessing.pde:63:3: error: 'in' was not declared in this scope
AnalogVisualizationProcessing.pde:63:12: error: expected type-specifier before 'ThresholdGraph'
AnalogVisualizationProcessing.pde:63:12: error: expected ';' before 'ThresholdGraph'
AnalogVisualizationProcessing.pde:70:5: error: 'threshMin' was not declared in this scope
AnalogVisualizationProcessing.pde:78:5: error: 'threshMax' was not declared in this scope
AnalogVisualizationProcessing.pde: In function 'void draw()':
AnalogVisualizationProcessing.pde:90:9: error: 'port1' was not declared in this scope
AnalogVisualizationProcessing.pde:96:32: error: 'println' was not declared in this scope
AnalogVisualizationProcessing.pde:103:3: error: 'in' was not declared in this scope
serialEvent.pde: In function 'void serialEvent(String)':
serialEvent.pde:4:18: error: 'Integer' was not declared in this scope
serialEvent.pde:4:47: error: 'class String' has no member named 'replaceAll'
serialEvent.pde:10:9: error: 'xPosArr' was not declared in this scope
serialEvent.pde:12:22: error: 'println' was not declared in this scope
serialEvent.pde:29:9: error: expected type-specifier before 'NumberFormatException'
serialEvent.pde:29:9: error: exception handling disabled, use -fexceptions to enable
serialEvent.pde:29:31: error: expected ')' before 'e'
serialEvent.pde:29:31: error: expected '{' before 'e'
serialEvent.pde:29:31: error: 'e' was not declared in this scope
serialEvent.pde:29:32: error: expected ';' before ')' token
serialEvent.pde:33:3: error: expected primary-expression before 'catch'
serialEvent.pde:33:3: error: expected ';' before 'catch'
thresHolding.pde: In function 'void threshHolding()':
thresHolding.pde:2:19: error: 'threshMin' was not declared in this scope
thresHolding.pde:3:16: error: 'threshMax' was not declared in this scope
thresHolding.pde:6:5: error: 'messageArr' was not declared in this scope
thresHolding.pde:6:20: error: 'xPosArr' was not declared in this scope
thresholdGraph.pde: At global scope:
thresholdGraph.pde:11:1: error: 'PFont' does not name a type
thresholdGraph.pde:71:1: error: expected ';' after class definition
thresholdGraph.pde:15:21: error: 'width' was not declared in this scope
thresholdGraph.pde:17:20: error: 'height' was not declared in this scope
thresholdGraph.pde:20:20: error: 'width' was not declared in this scope
thresholdGraph.pde: In constructor 'ThresholdGraph::ThresholdGraph()':
thresholdGraph.pde:25:3: error: 'font' was not declared in this scope
thresholdGraph.pde:25:27: error: 'loadFont' was not declared in this scope
thresholdGraph.pde:26:26: error: 'textFont' was not declared in this scope
thresholdGraph.pde: In member function 'void ThresholdGraph::update()':
thresholdGraph.pde:32:19: error: 'background' was not declared in this scope
thresholdGraph.pde:35:25: error: 'xPosArr' was not declared in this scope
thresholdGraph.pde:37:16: error: 'noStroke' was not declared in this scope
thresholdGraph.pde:38:15: error: 'fill' was not declared in this scope
thresholdGraph.pde:39:12: error: 'threshMin' was not declared in this scope
thresholdGraph.pde:39:86: error: 'rect' was not declared in this scope
thresholdGraph.pde:41:12: error: 'threshMax' was not declared in this scope
thresholdGraph.pde:56:82: error: 'text' was not declared in this scope
thresholdGraph.pde:60:13: error: 'stroke' was not declared in this scope
thresholdGraph.pde:61:19: error: 'strokeWeight' was not declared in this scope
thresholdGraph.pde:64:21: error: 'width' was not declared in this scope
thresholdGraph.pde:65:45: error: 'height' was not declared in this scope
thresholdGraph.pde:65:51: error: 'line' was not declared in this scope
thresholdGraph.pde:66:17: error: 'LEFT' was not declared in this scope
thresholdGraph.pde:66:21: error: 'textAlign' was not declared in this scope
thresholdGraph.pde:67:51: error: 'text' was not declared in this scope
编译有误。
报告将会包含更多的信息
"Show verbose output during compilation"
在 文件>首选项 中启用