Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
import processing.serial.*;
int lf = 10; // Linefeed in ASCII
String myString = null;
Serial myPort; // The serial port
int rad = 5; // Width of the shape
void setup() {
size(1024, 768);
// List all the available serial ports
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[5], 115200);
// Throw out the first reading, in case we started reading
// in the middle of a string from the sender.
myString = myPort.readStringUntil(lf);
myString = null;
void draw() {
while (myPort.available() > 0) {
myString = myPort.readStringUntil(lf);
String[] list = split(myString, ',');
ellipse(float(list[0]), float(list[1]), rad, rad);
ellipse(float(list[2]), float(list[3]), rad, rad);
ellipse(float(list[4]), float(list[5]), rad, rad);
ellipse(float(list[6]), float(list[7]), rad, rad);
if (myString != null) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment