Arduino-Processing Problem


so, i'm using book on ar , explains how connect arduino processing in order make ar application involves pressure sensor. however, when ran processing code through got error on "cam.play();" saying function play() not exist. if remove line, program runs crashes , produces error saying "error inside serial.<init>0." has baffled me past few hours. can please figure out. need project that's due soon.

here's arduino code. works

void setup() {
 serial.begin(9600);
}
void loop() {
serial.println(analogread(a0));
}

here's processing code. has problem.

import codeanticode.gsvideo.*;
import jp.nyatla.nyar4psg.*;
import processing.serial.*;

serial myport;
gscapture cam;
nyarmultiboard nya;
pfont font;

string instring = null;
float low = 3.0;
float high = 32.0;
float weight;

void setup() {
size(640,480,p3d);
println(serial.list());
myport = new serial(this, serial.list()[1], 9600);
myport.bufferuntil('\n');
font = loadfont("crystal-lightning-64.vlw");
cam=new gscapture(this,width,height);
cam.play();

string[] patts = {"scale16.pat"};
double[] widths = {80};
nya=new nyarmultiboard(this, width, height, "camera_para.dat", patts, widths);
print(nya.version);
nya.gsthreshold=120;
nya.cfthreshold=0.4;
}

void draw(){

 if (cam.available() !=true) {
 return;
}
cam.read();
hint(disable_depth_test);
image(cam,0,0);
hint(enable_depth_test);
if(nya.detect(cam)){
 if (nya.markers[0].detected){
   nya.markers[0].begintransform();
     textfont(font,25.0);
     textalign(center);
     fill(50,255,0);
     translate(0,50,80);
     rotatex(radians(180));
     rotatex(radians(90));
       text(weight,0,0,0);
     nya.markers[0].endtransform();
   }
 }
}
void serialevent  (serial myport) {
 instring = myport.readstringuntil('\n');
 if (instring != null) {
   instring = trim(instring);
   float val = float(instring);
   weight = 100+((val-low)*(100/(high-low)));
 }
}

code: [select]
println(serial.list());
myport = new serial(this, serial.list()[1], 9600);

the first line lists serial ports available. arduino @ second item in list?


Arduino Forum > Using Arduino > Programming Questions > Arduino-Processing Problem


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial