doggit
YaBB Newbies
Offline
Posts: 2
works w/ arduino, not w/ processing
Sep 30th , 2007, 12:03am
hello- any help would be appreciated. I'm on a Mac OS 10.4.10, have an Arduino mini 03 w/ usb hub, breadboarded w/ a photoresistor and LED. I've successfully interfaced with Arduino, running the LDR script from "Arduino Meets Processing." I can upload from Arduino, and the LED responds to light changes. Once I'm in Processing, there doesn't seem to be explicit communication with my board using the afore-mentioned script (pt 2, for Processing.) BUT the script doesn't give error feedback when played. I ran the SerialCallResponse script, and Processing applet would respond to ports 0 and 1, but not the others, so it seems that it is communicating. I'm not savvy enough to be able to break down the script well, so I am guessing that MAYBE that's the last possibility? I've pasted it in below. other troubleshooting I've done: 1) I've identified my serial port list using your script: [0] tty.usbserial-A4001kuq 2) put a momentary interrupt switch onto my board, used your example script "simpleread" without a response 3) pulled out all of the FTDI serial driver associated installs from Arduino's driver package (most recent)/ rebooted 4) reinstalled the FTDIserialdriver / reboot 5) ran macos_setup, gave me the "thumbs up" / reboot 6) tried my Processing/LDR script again, no response to the LDR sensor activation here's the Processing script from "Arduino meets Processing" site: /* * pa_LDR * * Reads the values which represent the state of a light sensor * from the serial port and draws a graphical representation. * * This file is part of the Arduino meets Processing Project. * For more information visit http://www.arduino.cc. * * copyleft 2005 by Melvin Ochsmann for Malmö University * */ // importing the processing serial class import processing.serial.*; // the display item draws background and grid DisplayItems di; // definition of window size and framerate int xWidth = 512; int yHeight = 512; int fr = 24; // attributes of the display boolean bck = true; boolean grid = true; boolean g_vert = true; boolean g_horiz = true; boolean g_values = false; boolean output = false; // variables for serial connection, portname and baudrate have to be set Serial port; String portname = "0"; int baudrate = 9600; int value = 0; String buf=""; int value1 = 0; // variables to draw graphics int x, y, cursorSize; int cnt = 6; // lets user control DisplayItems properties and value output in console void keyPressed(){ if (key == 'b' || key == 'B') bck=!bck; // background black/white if (key == 'g' || key == 'G') grid=!grid; // grid ON/OFF if (key == 'v' || key == 'V') g_values=!g_values; // grid values ON/IFF if (key == 'o' || key == 'O') output=!output; //turns value output ON/OFF } void setup(){ // set size and framerate size(xWidth, yHeight); frameRate(fr); // establish serial port connection port = new Serial(this, portname, baudrate); println(port); // create DisplayItems object di = new DisplayItems(); ellipseMode(CENTER); smooth(); } void drawLDRState(){ cnt++; if(cnt>24) cnt = 6; strokeWeight(2); stroke(0); noFill(); x = width/2; y = height/2; cursorSize = 5 + cnt*(value1/50); ellipse(x, y, cursorSize, cursorSize); stroke(255,0,0); ellipse(x, y, cursorSize-14, cursorSize-14); stroke(0,255,0); ellipse(x, y, cursorSize-8, cursorSize-8); stroke(0,0,255); ellipse(x, y, cursorSize-20, cursorSize-20); stroke(255); ellipse(x, y, cursorSize, cursorSize); } void serialEvent(int serial){ // if serial event is not a line break if(serial!=10) { // add event to buffer buf += char(serial); } else { // if serial is line break set value1 to buff and clear it value1 = 1023 - int(buf); // we inverse the value by subtracting it from the maximum buf=""; } if(output) println("LDR: "+value1); } // draw listens to serial port, draw void draw(){ // listen to serial port and trigger serial event while(port.available() > 0){ value = port.read(); serialEvent(value); } // draw background, then PushButtonState and finally rest of DisplayItems di.drawBack(); drawLDRState(); di.drawItems(); }