Go Down

Topic: processing code? (Read 1 time) previous topic - next topic

anthony8i

need help with processing code?I tried changing stuff around, tells me out of bound? changed ports around and still not processing right and i'm using port 4 can anyone see if it works on theirs? thanks for the help!

Code: [Select]


import processing.serial.*;

Serial myPort; 
PFont myFont;   

int j = 70;                   // counter
int inByte=0;
int wrote = 0;


void setup () {
  size(800, 600);        // window size
  frameRate(60);

  myFont = loadFont("ArialMT-12.vlw");
  textFont(myFont, 12);
  textAlign(LEFT);
 
  fill(#E9FF5B, 200);
  smooth();

  // set inital background:
  background(#000000, 200);
 
  println(Serial.list());
  myPort = new Serial(this, Serial.list()[2], 9600);



}

void draw()
{
fill(0,1);
  rect(0,0, width, height);
  stroke(255);
  strokeWeight(1);
  line(70,550,800,550);
  line(70,38,70,550);
  textFont(myFont, 16);
  fill(#FFFFFF);

  text("0V", 32, 550 );
  text("1", 32, 447 );
  text("2", 32, 345 );
  text("3", 32, 242 );
  text("4", 32, 140 );
  text("5V", 32, 37 );
 
  for (int i=0; i<6;i++){
    line(63,550-(i*102.4),77,550-(i*102.4));
  }
  stroke(230);
  strokeWeight(1);
   for (int i=0; i<6;i++){
    line(66,598.8-(i*102.4),74,598.8-(i*102.4));
  }
  while (myPort.available() > 0) {
    inByte = myPort.read()*2;
  }
 
   // if (inByte==254){
   //  incoming=myPort.read();
     // dev=myPort.read();
  //  }
   
  stroke(#555FFF,200);
  fill(255);

   line(j, 550-inByte, j,550);   
     

        // stroke(#55FF55,70);
   // fill(#FF555F);
  //ellipse(j, height/2 + dev, 2, 2);
   

  if (j > width) {
    j =70;
    background(#000000);
    fill(0,1);
    rect(0,0, width, height);
   }
  else {
    j++;
  }

if (wrote >20)
  {
  fill(#FFFFFF);
  textFont(myFont, 12);
  text(inByte/2, j,  (550- inByte)-30);
  wrote = 0;
  }
  wrote++;

}

ribbery45

The NIST withdrew the FIPS 55-3 database. This database included 5-digit numeric place codes for cities, towns, and villages, or other centers of population.

dxw00d


The NIST withdrew the FIPS 55-3 database. This database included 5-digit numeric place codes for cities, towns, and villages, or other centers of population.

What?

dxw00d

@anthony8i - Can you post the port list from
Code: [Select]
  println(Serial.list());

trendski

Hi,

I have also not been able to get this to work
Code: [Select]
myPort = new Serial(this, Serial.list()[2], 9600);

Try it wihout the [2].


If again no joy try this:
When I tried the same code on one of my projects a while ago, I had to use this instead:

Code: [Select]
import processing.serial.*;
Serial myPort;


void setup()
{
  size(800, 800); // pane size
 
myPort = new Serial(this, "COMn", 9600);




wher "n" is the port number. Use whatever you are using for port eg 2.



Craig Turner, blog: http://gampageek.blogspot.co.uk/ It helps with my learning if I write things down, esp. for others to follow (constructive comments welcomed to improve)

Go Up