Modified project14 for compatibility to Processing 3

This commit is contained in:
Arturo Guadalupi 2015-10-22 12:38:01 +02:00
parent 22dd1cbb99
commit d56e3848b4
1 changed files with 50 additions and 52 deletions

View File

@ -34,71 +34,69 @@ void loop() {
} }
/* Processing code for this example /* Processing code for this example
// Tweak the Arduno Logo // Tweak the Arduno Logo
// by Scott Fitzgerald // by Scott Fitzgerald
// This example code is in the public domain // This example code is in the public domain
// import the serial library // import the serial library
import processing.serial.*; import processing.serial.*;
// create an instance of the serial library // create an instance of the serial library
Serial myPort; Serial myPort;
// create an instance of PImage // create an instance of PImage
PImage logo; PImage logo;
// a variable to hold the background color // a variable to hold the background color
int bgcolor = 0; int bgcolor = 0;
void setup() { void setup() {
// set the color mode to Hue/Saturation/Brightness size(1, 1);
colorMode(HSB, 255); surface.setResizable(true);
// set the color mode to Hue/Saturation/Brightness
colorMode(HSB, 255);
// load the Arduino logo into the PImage instance // load the Arduino logo into the PImage instance
logo = loadImage("http://www.arduino.cc/en/pub/skins/arduinoWide/img/logo.png"); logo = loadImage("http://www.arduino.cc/arduino_logo.png");
// make the window the same size as the image // make the window the same size as the image
size(logo.width, logo.height); surface.setSize(logo.width, logo.height);
// print a list of available serial ports to the // print a list of available serial ports to the
// Processing staus window // Processing staus window
println("Available serial ports:"); println("Available serial ports:");
println(Serial.list()); println(Serial.list());
// Tell the serial object the information it needs to communicate // Tell the serial object the information it needs to communicate
// with the Arduno. Change Serial.list()[0] to the correct // with the Arduno. Change Serial.list()[0] to the correct
// port corresponding to your Arduino board. The last // port corresponding to your Arduino board. The last
// parameter (e.g. 9600) is the speed of the communication. It // parameter (e.g. 9600) is the speed of the communication. It
// has to correspond to the value passed to Serial.begin() in your // has to correspond to the value passed to Serial.begin() in your
// Arduino sketch. // Arduino sketch.
myPort = new Serial(this, Serial.list()[0], 9600); myPort = new Serial(this, Serial.list()[0], 9600);
// If you know the name of the port used by the Arduino board, you // If you know the name of the port used by the Arduino board, you
// can specify it directly like this. // can specify it directly like this.
// port = new Serial(this, "COM1", 9600); // port = new Serial(this, "COM1", 9600);
}
} void draw() {
void draw() { // if there is information in the serial port
if ( myPort.available() > 0) {
// read the value and store it in a variable
bgcolor = myPort.read();
// if there is information in the serial port // print the value to the status window
if ( myPort.available() > 0) { println(bgcolor);
// read the value and store it in a variable }
bgcolor = myPort.read();
// print the value to the status window // Draw the background. the variable bgcolor
println(bgcolor); // contains the Hue, determined by the value
} // from the serial port
background(bgcolor, 255, 255);
// Draw the background. the variable bgcolor
// contains the Hue, determined by the value
// from the serial port
background(bgcolor, 255, 255);
// draw the Arduino logo
image(logo, 0, 0);
}
// draw the Arduino logo
image(logo, 0, 0);
}
*/ */