@@ -66,24 +66,22 @@ void establishContact() {
66
66
}
67
67
}
68
68
69
-
70
- /*
71
- Processing code to run with this example:
69
+ /* Processing code to run with this example:
72
70
73
71
// This example code is in the public domain.
74
72
75
73
import processing.serial.*; // import the Processing serial library
76
74
Serial myPort; // The serial port
77
75
78
- float bgcolor; // Background color
79
- float fgcolor; // Fill color
80
- float xpos, ypos; // Starting position of the ball
76
+ float bgcolor; // Background color
77
+ float fgcolor; // Fill color
78
+ float xpos, ypos; // Starting position of the ball
81
79
82
80
void setup() {
83
- size(640,480);
81
+ size(640, 480);
84
82
85
83
// List all the available serial ports
86
- // if using Processing 2.1 or later, use Serial.printArray()
84
+ // if using Processing 2.1 or later, use Serial.printArray()
87
85
println(Serial.list());
88
86
89
87
// I know that the first port in the serial list on my Mac is always my
@@ -114,25 +112,25 @@ void establishContact() {
114
112
// read the serial buffer:
115
113
String myString = myPort.readStringUntil('\n');
116
114
// if you got any bytes other than the linefeed:
117
- myString = trim(myString);
118
-
119
- // split the string at the commas and convert the sections into integers:
120
- int sensors[] = int(split(myString, ','));
121
-
122
- // print out the values you got:
123
- for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
124
- print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
125
- }
126
- // add a linefeed after all the sensor values are printed:
127
- println();
128
- if (sensors.length > 1) {
129
- xpos = map(sensors[0], 0,1023,0,width);
130
- ypos = map(sensors[1], 0,1023,0,height);
131
- fgcolor = sensors[2];
132
- }
133
- // send a byte to ask for more data:
134
- myPort.write("A");
115
+ myString = trim(myString);
116
+
117
+ // split the string at the commas and convert the sections into integers:
118
+ int sensors[] = int(split(myString, ','));
119
+
120
+ // print out the values you got:
121
+ for (int sensorNum = 0; sensorNum < sensors.length; sensorNum++) {
122
+ print("Sensor " + sensorNum + ": " + sensors[sensorNum] + "\t");
123
+ }
124
+ // add a linefeed after all the sensor values are printed:
125
+ println();
126
+ if (sensors.length > 1) {
127
+ xpos = map(sensors[0], 0, 1023, 0, width);
128
+ ypos = map(sensors[1], 0, 1023, 0, height);
129
+ fgcolor = sensors[2];
135
130
}
131
+ // send a byte to ask for more data:
132
+ myPort.write("A");
133
+ }
136
134
137
135
*/
138
136
0 commit comments