Sketch 160602b

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

import processing.serial.

*;

Serial port;
int word;
byte[] inByte;
int count = 0;
int flag = 0;

void setup(){
println(Serial.list()[1]);
String arduinoPort = Serial.list()[1];
port = new Serial(this, arduinoPort, 9600); // Arduino

inByte = new byte[450];

size(480,320);
noLoop();
}

void draw(){

inByte = port.readBytes();
port.readBytes(inByte);
if (inByte != null) {
String myString = new String(inByte);
println(myString+"\n");
}
/*
background(255);
for(int i = 0; i< 225; i++){
print(int(inByte[i]) + " ");
fill(int(inByte[i])*2.4);
rect((i%15)*10, i/15*10 , 10, 10);
}
print("\n");
for(int i = 0; i< 225; i++){
print(int(inByte[i+225]) + " ");
fill(int(inByte[i+225])*2.4);
rect((i%15)*10 + 150, i/15*10 , 10, 10);
}
count = 0;
*/
}
/*
void serialEvent(Serial port){
word = port.read();
if(char(word) == 'A'){
flag = 1;
}
if(flag == 1){

if(char(word) == 'Z'){
redraw();
flag = 0;
}else{
inByte[count++] = word;
}
port.readBytesUntil(int('Z'), inByte);
flag = 0;
redraw();
}
// print(word+" ");

}
*/

// if (port.available() >= 225 ) {


// if(port.read() == 'H'){
// for(int i = 0; i< 225; i++){
// inByte[i] = port.read();
// }
// }
// }

// delay(10);
// inByte=port.read();
// if (inByte == 1){
// count = 0;
// noLoop();
// }

You might also like