import processing.video.*; /* Multi-byte serial example using punctuation Language: Processing This example listens for a four-byte "sentence" from a microcontroller. It treats the first three bytes as sensor readings, and uses them to move a ball on the screen. The sensor readings can range from 0 - 254. An incoming byte of value 255 is interpreted as the end of the sentence, Created 3 Oct. 2007 by Tom Igoe */ import processing.serial.*; //Serial myPort; // the instance of the Serial class //int[] sensorArray = new int[2]; // Array to hold the incoming sensor values //int arrayCounter = 0; // counter for the array elements float s; float s1; void setup() { // set up the window: size (400,400); smooth(); frameRate(30); // list all the serial ports: //println(Serial.list()); // pick the serial port that corresponds to your Arduino: //String portname = Serial.list()[0]; // open the port by instantiating the Serial class: //myPort = new Serial(this, Serial.list()[0], 9600); desta forma n se precisa de definir a variavel port name // myPort = new Serial(this, portname, 9600); //println(sensorArray[0]); //println(sensorArray[1]); } void draw() { // clear the window background: background(255); // use the Z axis of the accelerometer to set the grayscale of the ball: // use the X and Y axes to move the ball: for (int i = 0; i < 15; i++){ for (int j = 0; j < 15; j++){ ellipseMode(CENTER); fill(200,random(0,255)*2 ,0,random(0,255) ); //noStroke(); ellipse(i*30,j*30, s, s1); s = 20; s1 = 30; s +=103; s1 +=103; println(mouseX); //constrain println(s); } } } /* void serialEvent(Serial myPort) { // read the incoming byte: int inByte = myPort.read(); // if the byte is 255, it's the end of a set of sensor readings. // reset the array counter to get the next set of readings: if (inByte == 255) { arrayCounter = 0; } // if the inByte is not 255, it's a sensor reading. Put it // in the appropriate array element: else { sensorArray[arrayCounter] = inByte; // increment the array counter: arrayCounter++; } } */