Arduino + Processing for Graphing


i tried following:

http://www.arduino.cc/en/tutorial/graph

i put arduino sketch in same folder/directory processing sketch when verify arduino sketch error:

variable or field 'serialevent' declared void.

so doing wrong?

i forgot post code:

arduino:

code: [select]
void setup() {
  // initialize serial communication:
  serial.begin(115200);
}

void loop() {
  // send value of analog input 0:
  serial.println(analogread(a0));
  // wait bit analog-to-digital converter
  // stabilize after last reading:
  delay(2);
}


processing code:

code: [select]

import processing.serial.*;

serial myport;        // serial port
int xpos = 1;         // horizontal position of graph

void setup () {
   // set window size:
   size(400, 300);       
   // list available serial ports
   println(serial.list());
   // know first port in serial list on mac
   // my  arduino, open serial.list()[0].
   // open whatever port 1 you're using.
   myport = new serial(this, serial.list()[2], 9600);
   // don't generate serialevent() unless newline character:
   myport.bufferuntil('\n');
   // set inital background:
   background(0);
}

void draw () {
   // happens in serialevent()
}

void serialevent (serial myport) {
   // ascii string:
   string instring = myport.readstringuntil('\n');
   
   if (instring != null) {
     // trim off whitespace:
     instring = trim(instring);
     // convert int , map screen height:
     float inbyte = float(instring);
     inbyte = map(inbyte, 0, 1023, 0, height);
     
     // draw line:
     stroke(127,34,255);
     line(xpos, height, xpos, height - inbyte);
     
     // @ edge of screen, go beginning:
     if (xpos >= width) {
       xpos = 0;
       background(0);
     } else {
       // increment horizontal position:
       xpos++;
     }
   }
}



Arduino Forum > Using Arduino > Interfacing w/ Software on the Computer > Arduino + Processing for Graphing


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

Rasperry Wifi LAN Controller - Raspberry Pi Forums

Unlock car with bluetooth and car key