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:
when start processing message sun java , have openjdkwarning: rxtx version mismatch
jar version = rxtx-2.2pre1
native lib version = rxtx-2.2pre2
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
processing codecode: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); }
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:
, here processing code:code:int intvalue; void setup() { serial.begin(9600); } void loop() { intvalue = analogread(0); serial.print(intvalue, dec); }
the message window in processing prints out: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); } }
/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
Post a Comment