BRITOV DENIS

Status:

COMPLEATED

 

Week 14: interface and application programming

At this week i should write an application that interfaces with my light sensor.

l`d like to try Processing program language.

You can download processing here:

 

http://processing.org/download

 

It looks like arduino ide.

Here is nice Getting started tutorial, whick helps me a lot:

 

https://processing.org/tutorials/gettingstarted/

 

And some usefull information about serial port communication:

 

https://processing.org/reference/libraries/serial/index.html

 

So, let starts. There is little comands to understand how it works.

The main - to include necessery library, for us it is processing.serial.*;

I called my serial port myDev, it is 3 in the list, so to use it:

myDev = new Serial(this, Serial.list()[2], 9600);

All other skills is drawing, my program draws colored circles:

 

import processing.serial.*;

Serial myDev;

void setup() {

  size(500, 500);

  background(255);

  println(Serial.list());

  myDev = new Serial(this, Serial.list()[2], 9600);

}

 

void draw() {

  while (myDev.available () > 0) {

    int data = myDev.read();

    println(data);

    noStroke();

    fill(data,255-data,255-data);

    ellipse(256,256,data,data);

 

  }

}

 

Video: