/** * Simple Write. * * Check if the mouse is over a rectangle and writes the status to the serial port. * This example works with the Wiring / Arduino program that follows below. */ import processing.serial.*; Serial myPort; // Create object from Serial class int val; // Data received from the serial port int distances[] = {20, -20}; //int speeds[] ={1000, 1100, 1200, 1300, 1400, 1500}; int speeds[] ={13?00, 1400, 1500, 1600, 1700, 1800}; void setup() { size(200, 200); // I know that the first port in the serial list on my mac // is always my FTDI adaptor, so I open Serial.list()[0]. // On Windows machines, this generally opens COM1. // Open whatever port is the one you're using. println(Serial.list()); String portName = Serial.list()[4]; myPort = new Serial(this, portName, 9600); } void draw() { background(255); for (int i=0; i<6; i++) { println("testing speed "+speeds[i]); myPort.write("G1 Y"+distances[0]+" F"+speeds[i]+"\n"); delay(1000); myPort.write("G1 Y"+distances[1]+" F"+speeds[i]+"\n"); delay(1000); } }