Week 16 - Interface and application programming

This week we have to use a board from previous assigments and write an application that interfaces with it.

I chose to use a board of input assignment with a light sensor and Processing program using an interface which receive sensor data via cable FTDI

Using Processing

It's my first time using Processing so I have started from a simple read example from Processing.

I noticed in another practice another year where the modified code SimpleRead to draw a circle.
I found the following problems:
To ensure that the sensor worked first thing I connected to Arduino noting that receiving data, it's works!

When trying to connect to Processing I realized that did not receive data from the usbserial so I had to a bit more research ...

I made a list of serial and I "discovered" that the right is the second in the list:

 

//import serial library
import processing.serial.*;

Serial serialPort; // Create object from Serial class
int diameter= 500; // initial diameter of the circle
String buf;
int lightIn;

void setup() {
size(500, 500);
// I know that the first port in the serial list on my mac
// is always my FTDI adaptor, so I open Serial.list()[0].
// On Windows machines, this generally opens COM1.
// Open whatever port is the one you're using.
println("listado de serials");
//println(Serial.list());

String portTwo = Serial.list()[2];
println(portTwo);
serialPort = new Serial(this, portTwo, 9600);

 

The second problem I found was that the data sent from Arduino did not read correctly into Processing, since it only reads "integers". I have to write some code.

 

// this is for convert data from arduino in integers
void serialEvent(char digito) {
if (digito>=47 && digito<=57) { //digito>='0' && digito<='9' || digito=='/') {
buf += digito;
} else if (digito == 13) {
lightIn = int(buf);
buf = "";

First I created a ball that gets bigger the less light to enter the sensor.
In the second case I had that same ball random colors.

light stepper with processing from Jose Real on Vimeo.

light stepper with processing 2 from Jose Real on Vimeo.

WHAT I HAVE LEARNED?

Processing is a very powerful tool for managing data received from sensors, Arduino, etc. I think that eventually learn to use it better to apply to architectural projects, as I think it is not using its potential in this environment, although you can see interesting projects such as LED facades.

I have learned that different languages can understand and that seems very interesting. Contectar Arduino with Processing is fine, but I would like to learn how to connect both with Grasshopper. The hardest part has been able to read that data from Arduino Processing

INTERFACE AND APPLICATION PROGRAMMING
Described your process using words/images/screenshots
X
Explained the protocols you used
X
Had a fun time
X
Outlined problems and how you fixed them
X
Included original code
X

FILES

processing code

fablabueMIT