import processing.serial.*;
Serial myPort; // The serial port:
int backValue = 255; // Declare variable 'backValue' and assign it the value 255
void setup() { // The setup() function is run once, when the program starts. It's used to define initial enviroment properties.
size(640, 360);
background(backValue);
printArray(Serial.list()); // List all the available serial ports:
myPort = new Serial(this, "COM5", 9600); // Open the port you are using at the rate you want:
}
void draw() { // Called directly after setup(), the draw() function continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called.
}
void mousePressed() { //The mousePressed() function is called once after every time a mouse button is pressed.
if (backValue == 255) { //If the test evaluates to true, the statements enclosed within the block are executed
backValue = 10;
myPort.write(0); //low
} else { //It specifies a block of code to execute when the expression in if is false.
backValue = 255;
myPort.write(1); //high
}
background(backValue);
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}