Skip to main content

Thread: Arduino and Processing language


i trying use uno simple oscilloscope having problem processing not receiving data arduino.
decided use simpler code arduino cookbook , have simplified more.
both compile , processing code displays white box
no rectangle drawn , line: println("message received: " + value2);
not show in processing ide message window.
this:
warning: rxtx version mismatch
jar version = rxtx-2.2pre1
native lib version = rxtx-2.2pre2
when start processing message sun java , have openjdk
have tried find out how can install , use sun java jdk
lost lot of have depends on openjdk
, have not been able find out how install sun java sfuff anyway.
having read various instructions keep finding have ,
not correspond instructions.
running ubuntu 10.10

if run serial monitor in arduino ide characters displayed
can see arduino code working.
make simple possible on hardware side have 10k pot connected +5v > 1 end of pot, arduino analog(0) > centre of pot, ground > other end of pot.

ideas how solve problem please?

arduino code
code:
int intvalue; void setup() {   serial.begin(9600); }  void loop() {   serial.print('h');   intvalue = analogread(0);   serial.print(lowbyte(intvalue), byte);   serial.print(highbyte(intvalue), byte);   delay(100); }
processing code
code:
import processing.serial.*; serial myport; short portindex;  char header = 'h'; float startx, starty, value1, value2;  void setup() { size(600, 600);  myport = new serial(this, "/dev/ttyacm0", 9600);  } void draw() {  if (myport.available() >= 3)  {    if(myport.read() == header )    {      value1 = myport.read();      value2 = myport.read() * 256  + value1; println("message received: " + value2);    } } background(255); fill(0); rect(startx, starty, value1, value2); }

i have tried different code still doesn't had hoped.

arduino code:
code:
int intvalue; void setup() {   serial.begin(9600); }  void loop() {      intvalue = analogread(0); serial.print(intvalue, dec);  }
, here processing code:
code:
 import processing.serial.*; serial port; // create object serial class int val; // data received serial port int ypos = 0; void setup() { size(800, 400); strokeweight(2); // important note: // first serial port retrieved serial.list() // should arduino. if not, uncomment next // line deleting // before it. run sketch // again see list of serial ports. then, change // 0 in between [ , ] number of port // arduino connected to. println(serial.list()); string arduinoport = serial.list()[0]; port = new serial(this, arduinoport, 9600); } void draw() { //  delay(10); if (port.available() >0) { val = port.read(); // if data available, // read , store in val point(ypos, val ); ypos += 1; println(val);  } if(ypos >799) {    ypos=0;   background(204); }   }
the message window in processing prints out:

/dev/ttyacm0

correct
prints 52 48 52 48 on , on no matter how adjust potentiometer.

ideas anyone?


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] Arduino and Processing language


Ubuntu

Comments

Popular posts from this blog

how to devide a circle into equal parts

"Could not fill because there are not enough opaque source pixels" - not solved by any other thread

Why can't I change the billing info for my account?