▁▃▅▇█FILE:006█▇▅▃▁
:: WORKSHOP ::
[Paul demostrate how to connect the BX with computer by Processing and how to change the color in the output window by changing the variable resistor. however, because of going to Reading, so i cannot participate the whole workshop]
[code of Processing]
import processing.serial.*;
String buff = "";
int val = 0;
int NEWLINE = 10;
PImage b;
Serial port;
void setup()
{
size(400, 400);
// Print a list in case COM1 doesn't work out
println("Available serial ports:");
println(Serial.list());
//port = new Serial(this, "COM1", 19200);
// Uses the first available port
port = new Serial(this, Serial.list()[0], 19200);
}
void draw()
{
while (port.available() > 0) {
serialEvent(port.read());
}
background(val);
fill(80, 80, 80);
ellipse(val, val, 50, 50);
b = loadImage("trial.jpg");
image(b, 0, val, width, val);
}
void serialEvent(int serial)
{
// If the variable "serial" is not equal to the value for
// a new line, add the value to the variable "buff". If the
// value "serial" is equal to the value for a new line,
// save the value of the buffer into the variable "val".
if(serial != NEWLINE) {
buff += char(serial);
} else {
buff = buff.substring(0, buff.length()-1);
// Parse the String into an integer
val = Integer.parseInt(buff)/4;
println(val);
// Clear the value of "buff"
buff = "";
}
}
[code of BX-24]
Sub main()
call delay(0.5) ' start with half-second delay
do
' returns values between 0 and 1023
' the variable resistor is in pin 18
debug.print cstr(getADC(18))
call delay(0.1) ' one-tenth second delay
loop
end sub
:: INSPIRATION/RΣSΣARCH ::
[ Processing Beta 093 was installed this week, i am spending time to play with the examples and trying to understand the codes... i found some codes like //import processing.video.*;// and //void captureEvent(Capture camera)//, which should be useful for my programme.]
:: WORKSHOP ::
[Paul demostrate how to connect the BX with computer by Processing and how to change the color in the output window by changing the variable resistor. however, because of going to Reading, so i cannot participate the whole workshop]
[code of Processing]
import processing.serial.*;
String buff = "";
int val = 0;
int NEWLINE = 10;
PImage b;
Serial port;
void setup()
{
size(400, 400);
// Print a list in case COM1 doesn't work out
println("Available serial ports:");
println(Serial.list());
//port = new Serial(this, "COM1", 19200);
// Uses the first available port
port = new Serial(this, Serial.list()[0], 19200);
}
void draw()
{
while (port.available() > 0) {
serialEvent(port.read());
}
background(val);
fill(80, 80, 80);
ellipse(val, val, 50, 50);
b = loadImage("trial.jpg");
image(b, 0, val, width, val);
}
void serialEvent(int serial)
{
// If the variable "serial" is not equal to the value for
// a new line, add the value to the variable "buff". If the
// value "serial" is equal to the value for a new line,
// save the value of the buffer into the variable "val".
if(serial != NEWLINE) {
buff += char(serial);
} else {
buff = buff.substring(0, buff.length()-1);
// Parse the String into an integer
val = Integer.parseInt(buff)/4;
println(val);
// Clear the value of "buff"
buff = "";
}
}
[code of BX-24]
Sub main()
call delay(0.5) ' start with half-second delay
do
' returns values between 0 and 1023
' the variable resistor is in pin 18
debug.print cstr(getADC(18))
call delay(0.1) ' one-tenth second delay
loop
end sub
:: INSPIRATION/RΣSΣARCH ::
[ Processing Beta 093 was installed this week, i am spending time to play with the examples and trying to understand the codes... i found some codes like //import processing.video.*;// and //void captureEvent(Capture camera)//, which should be useful for my programme.]

0 Comments:
Post a Comment
<< Home