Skip to content

Instantly share code, notes, and snippets.

@starlightme
Created November 26, 2015 14:41
Show Gist options
  • Save starlightme/a786b4282a20b3e69eab to your computer and use it in GitHub Desktop.
Save starlightme/a786b4282a20b3e69eab to your computer and use it in GitHub Desktop.
receive serial data and plot
int i;
void setup(){
Serial.begin(9600);
}
void loop(){
i++;
Serial.write(150 + i);
delay(1000);
}
import processing.serial.*;
Serial myPort; // The serial port
void setup() {
size(400,400);
smooth();
// List all the available serial ports
printArray(Serial.list());
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[0], 9600);
}
void draw() {
while (myPort.available() > 0) {
int inByte = myPort.read();
println(inByte);
ellipse(200,inByte,100,100);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment