Assignment XVI Interface and application programming

HOW DOES IT FUNCTION? WATCH THE VIDEO INTERFACES

Firstly, learn the code of processing and practice doing simple tasks. Here you`ve got an example I made

I suggest you this tutorial. Its really useful and complete.

The code, I`ve used is this one:

import processing.serial.*;
int end=10;
String serial;
Serial port;
char byte1=0;
char byte2=0;

void setup() {
String[] aa=Serial.list();
for (int i=0;i<aa.length;i++) {
println("["+i+"]"+aa[i]);
}

port = new Serial(this, Serial.list()[5], 9600);
port.clear();
serial = port.readStringUntil(end);
serial = null;

size(300, 300);
background(255);

}

boolean flag=false;

void draw() {
background(255);

int data=int(port.readChar());


println(data);
if (data==100){
flag=true;
}else if (data==117){
flag=false;
}else{
flag=flag;
}
drawRecSwitch(flag);
}

void drawRecSwitch(boolean status){
if (status){
fill(160,103,201);
rect(width/2-50,height/2-50,100,100);
}else{
fill(103,201,115);
rect(width/2-50,height/2-50,100,100);
}
}